Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Cloud Text To Speech

Cloud Text To Speech Laravel Package

google/cloud-text-to-speech

Idiomatic PHP client for Google Cloud Text-to-Speech. Install with Composer, authenticate, and call the API via TextToSpeechClient to list voices and synthesize speech, with generated classes and error handling.

View on GitHub
Deep Wiki
Context7

google/cloud-text-to-speech is the official, idiomatic PHP client for Google Cloud Text-to-Speech, part of the Google Cloud PHP family. It gives PHP applications direct access to the V1 API through typed request and response objects and generated client classes such as TextToSpeechClient, with authentication and transport handled by Google ApiCore.

composer require google/cloud-text-to-speech
  • Synthesize speech from plain text or SSML in dozens of languages and voices.
  • List voices and inspect supported languages, genders, and sample rates.
  • Choose audio encodings like MP3, LINEAR16, and OGG_OPUS.
  • GA stability — no backwards-incompatible changes in minor or patch releases.
Frequently asked questions about Cloud Text To Speech
How do I install google/cloud-text-to-speech in a Laravel app?
Install it with Composer by running composer require google/cloud-text-to-speech in your Laravel project. Then authenticate with Google Cloud and optionally bind TextToSpeechClient as a singleton in a custom service provider. You can start by calling listVoices or synthesizeSpeech from a service class.
Does google/cloud-text-to-speech support Laravel 10 and PHP 8.1?
The package is GA and tested with PHP 8.1+, which aligns with Laravel 10 and newer supported versions. You should still verify the Composer platform requirements against your exact Laravel and PHP versions. Laravel 10+ applications running PHP 8.1 or higher are the safest fit.
How do I authenticate Google Cloud Text-to-Speech in Laravel?
Create a Google Cloud service account, download the JSON key, and point GOOGLE_APPLICATION_CREDENTIALS at it or load credentials through google/auth. Store the key securely using environment variables or a secrets manager rather than committing it. Then initialize TextToSpeechClient in a Laravel service provider or dedicated service class.
Can I use google/cloud-text-to-speech for asynchronous audio generation with Laravel Queues?
Yes, this package fits well with Laravel Queues for asynchronous TTS processing. Wrap TextToSpeechClient in a service class, dispatch a job such as SynthesizeAudioJob, and process it with queue workers or Laravel Horizon. This avoids blocking user requests during audio generation and helps handle retries.
What audio formats and voices can I generate with this Laravel TTS package?
It exposes Google Cloud Text-to-Speech voices and supports synthesis input including plain text and SSML. Audio output can be requested in formats such as MP3, LINEAR16, and OGG_OPUS depending on the voice and API configuration. Use listVoices to discover available voices and their supported language codes and formats.
How should I handle binary audio responses and storage in Laravel?
The synthesizeSpeech response includes binary audio content that you should save through Laravel's Filesystem or stream directly in a response. Store generated files on local disk, S3, or another configured disk, and avoid holding large audio strings in memory. For user downloads, return a streamed response with the correct audio MIME type.
How do I handle Google Cloud TTS rate limits, quota errors, and ApiException in Laravel?
Catch the package's ApiException around calls and inspect the status code to distinguish rate limits, quota errors, and authentication failures. Use Laravel queue retries with exponential backoff for transient failures, and log persistent errors for alerting. Avoid tight retry loops and monitor Google Cloud quotas and billing to prevent cost spikes.
Is google/cloud-text-to-speech suitable for real-time low-latency TTS in Laravel?
It is best suited for non-real-time or batch TTS workloads rather than strict low-latency live generation. For frequent phrases, cache or pre-generate audio in Redis or object storage to reduce API calls. If you need sub-500ms responses, consider a hybrid approach with pre-generated voices or a local TTS fallback.
What are alternatives to google/cloud-text-to-speech for Laravel TTS?
Common alternatives include AWS Polly, Azure Text-to-Speech, and local PHP or system TTS libraries such as easyspeech as a fallback. Compare voice quality, SSML support, audio formats, latency, and pricing for your expected volume. You can also keep a local fallback for outages or cost control.
Is google/cloud-text-to-speech GA and actively maintained for production Laravel use?
Yes, this component is GA with a stable API and is part of Google Cloud PHP. Google states it will not introduce backwards-incompatible changes in minor or patch releases, and support requests go through the main google-cloud-php repository. That makes it reasonable for production Laravel use, provided you pin versions and monitor the changelog.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo