pascalkleindienst/laravel-text-to-speech
Composer 安装命令:
composer require pascalkleindienst/laravel-text-to-speech
包简介
This is my package laravel-text-to-speech
README 文档
README
A simple and elegant Laravel package that converts text to speech using various TTS engines. Easily integrate voice synthesis into your Laravel applications with support for multiple languages, voices, and audio formats.
Features
- 🎤 Multiple TTS engine support
- 🌍 Multi-language compatibility
- 🔊 Customizable voice options
- ⚡️ Simple, fluent API
- 🚀 Easy Laravel integration
Perfect for creating accessible applications, voice notifications, audiobooks, or any project requiring speech synthesis.
📖️ Installation
You can install the package via composer:
composer require pascalkleindienst/laravel-text-to-speech
You can publish the config file with:
php artisan vendor:publish --tag="laravel-text-to-speech-config"
This is the contents of the published config file:
return [ 'driver' => env('TEXT_TO_SPEECH_DRIVER'), 'language' => env('TEXT_TO_SPEECH_LANGUAGE'), 'audio' => [ 'path' => env('TEXT_TO_SPEECH_AUDIO_PATH', 'audio'), 'format' => env('TEXT_TO_SPEECH_AUDIO_FORMAT', 'mp3'), 'disk' => env('TEXT_TO_SPEECH_AUDIO_DISK', 'local'), ], 'google' => [ 'private_key' => env('TEXT_TO_SPEECH_GOOGLE_PRIVATE_KEY'), 'type' => env('TEXT_TO_SPEECH_GOOGLE_TYPE', 'service_account'), 'client_email' => env('TEXT_TO_SPEECH_GOOGLE_CLIENT_EMAIL'), 'voice' => env('TEXT_TO_SPEECH_GOOGLE_VOICE', 'de-DE-Chirp3-HD-Achernar'), ], 'polly' => [ 'key' => env('TEXT_TO_SPEECH_POLLY_KEY'), 'secret' => env('TEXT_TO_SPEECH_POLLY_SECRET'), 'token' => env('TEXT_TO_SPEECH_POLLY_TOKEN', false), 'version' => env('TEXT_TO_SPEECH_POLLY_VERSION', 'latest'), 'region' => env('TEXT_TO_SPEECH_POLLY_REGION', 'us-east-1'), 'format' => env('TEXT_TO_SPEECH_POLLY_FORMAT', 'mp3'), 'engine' => env('TEXT_TO_SPEECH_POLLY_ENGINE', 'standard'), 'voice' => env('TEXT_TO_SPEECH_POLLY_VOICE', 'Joanna'), 'text_type' => env('TEXT_TO_SPEECH_POLLY_TEXT_TYPE', 'text'), ], 'system' => [ 'rate' => env('TEXT_TO_SPEECH_SYSTEM_RATE', 175), 'pitch' => env('TEXT_TO_SPEECH_SYSTEM_PITCH', 50), 'volume' => env('TEXT_TO_SPEECH_SYSTEM_VOLUME', 100), 'voice' => env('TEXT_TO_SPEECH_SYSTEM_VOICE', 'german-mbrola-1'), ], ];
Driver Prequisites
System Driver
When using the system driver, you need to install the following packages:
Google Driver
When using the google driver, you need to install the following packages:
composer require google/cloud-text-to-speech
💻 Usage
use PascalKleindienst\LaravelTextToSpeech\Facades\TextToSpeech; use PascalKleindienst\LaravelTextToSpeech\Source; // The text is converted to speech and stored in a file (configured in the "audio" config). TextToSpeech::convert('Hello World!'); // The text is converted to speech and additionallystored in the given file. TextToSpeech::convert('Hello World!')->save('path/to/file.mp3'); // Store the converted text on a different disk TextToSpeech::convert('Hello World!')->disk('s3')->save('path/to/file.txt'); // convert text from a file TextToSpeech::from(Source::File)->convert('path/to/file.txt'); /** * Change the language and/or voice used for the speech. * NOTE: * This will overwrite the language and voice settings in the config file. * Also the format for the language might be different for each engine, e.g. de vs de-DE */ TextToSpeech::language('de-DE')->voice('male')->convert('Hallo Welt!'); // Use the system engine to convert text to speech, needs espeak-ng to be installed TextToSpeech::engine('system')->convert('Hello System Engine!'); // Use the Google engine to convert text to speech, needs google cloud sdk to be installed TextToSpeech::engine('google')->convert('Hello Google Engine!');
👨🔬 Testing
composer test
📝 Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
pascalkleindienst/laravel-text-to-speech 适用场景与选型建议
pascalkleindienst/laravel-text-to-speech 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 81 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 05 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「Pascal Kleindienst」 「laravel-text-to-speech」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 pascalkleindienst/laravel-text-to-speech 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pascalkleindienst/laravel-text-to-speech 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 pascalkleindienst/laravel-text-to-speech 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Convert strings between 13 naming conventions: Snake case, Camel case, Pascal case, Kebab case, Ada case, Train case, Cobol case, Macro case, Upper case, Lower case, Sentence case, Title case and Dot notation.
Symfony2 Case Converter Bundle
Symfony Case Converter Bundle
Converts the camel case and snake case each other.
Alfabank REST API integration
Fluent-style string operations
统计信息
- 总下载量: 81
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-30