- Can I use this package on Linux servers or cloud platforms like AWS/GCP?
- No, this package requires Microsoft Edge to be installed on the server, which is Windows-only. You’d need a Windows-based environment (e.g., a VM, Docker Windows container, or shared Windows hosting) to run it. Linux-based cloud platforms like AWS or GCP are not supported without workarounds like Wine or virtualization.
- How do I install and configure the package for Laravel?
- First, run `composer require bestmomo/laravel-edge-tts`, then publish the config file with `php artisan vendor:publish --tag=edge-tts-config`. Edit `config/edge-tts.php` to set your default voice, middleware (e.g., auth, throttle), caching settings, and logging preferences. Ensure Microsoft Edge is installed on your server.
- What Laravel versions does this package support?
- This package requires **PHP 8.1+** and is built for **Laravel 9+**. If you’re using an older Laravel version, you’ll need to upgrade or check for compatibility updates, as the package leverages modern Laravel features like contracts and facades.
- How do I generate and stream audio using the package?
- Use the facade `EdgeTTS::textToSpeech('Your text', 'voice-code', 'output.mp3')` or inject the `TtsSynthesizer` contract. The package automatically handles streaming via a dedicated route (configurable with middleware). For caching, set `cache.enabled` to `true` in the config and specify a Laravel disk (e.g., `local`, `s3`).
- Is there a way to secure the TTS streaming route?
- Yes, the package includes middleware support for the streaming route. In `config/edge-tts.php`, define an array of middleware like `['auth', 'throttle:60,1']` to restrict access. This ensures only authenticated or rate-limited users can generate audio, protecting your API from abuse.
- Can I cache generated MP3 files to improve performance?
- Absolutely. Enable caching by setting `'cache.enabled' => true` in the config and specify a Laravel disk (e.g., `local`, `s3`). Optionally, set `'cache.lifetime'` to define how long cached files should persist. The package stores MP3s in the configured disk and serves them directly for repeated requests.
- What happens if Microsoft Edge’s TTS API changes or breaks?
- This package relies on the underlying `andresayac/edge-tts-php` library, which interacts with Edge’s internal API. If Microsoft modifies or deprecates Edge’s TTS functionality, the package may break. Monitor updates to the base library and consider fallback mechanisms (e.g., cloud TTS services) if reliability is critical.
- Are there alternatives to this package for Laravel TTS?
- Yes. For cloud-based TTS, consider packages like `spatie/laravel-aws-polly` (AWS Polly) or `responsivevoice/responsive-voice` (browser-based). For local TTS on Linux, explore `espeak` or `festvox`. However, these alternatives may require API keys, subscriptions, or different deployment setups compared to Edge TTS’s local-first approach.
- How do I handle concurrent requests or high traffic with Edge TTS?
- Edge TTS is not thread-safe by default, so concurrent requests may cause performance issues or failures. Use middleware like `throttle` to limit requests, and consider offloading generation to Laravel queues if processing heavy text. For high-scale needs, evaluate cloud TTS services instead, as they’re designed for horizontal scaling.
- Does this package support advanced TTS features like SSML or voice customization?
- No, this package wraps Microsoft Edge’s basic TTS functionality, which lacks advanced features like SSML (Speech Synthesis Markup Language) or prosody control. If you need these, consider cloud-based TTS services (e.g., AWS Polly, Google Cloud Text-to-Speech) or local engines like `espeak` with custom scripts.