Download the PHP package moe-mizrak/laravel-google-text-to-speech without Composer
On this page you can find all versions of the php package moe-mizrak/laravel-google-text-to-speech. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download moe-mizrak/laravel-google-text-to-speech
More information about moe-mizrak/laravel-google-text-to-speech
Files in moe-mizrak/laravel-google-text-to-speech
Package laravel-google-text-to-speech
Short Description Laravel package for integrating Gemini Text-to-Speech API and Google Cloud Text-to-Speech API
License MIT
Homepage https://github.com/moe-mizrak/laravel-google-text-to-speech
Informations about the package laravel-google-text-to-speech
Laravel Gemini and Google Cloud Text-to-Speech API Package
Laravel package for integrating Gemini Text-to-Speech API and Google Cloud Text-to-Speech API
Requirements
- PHP: 8.4 or higher
- Google Cloud account with access to Gemini API and/or Cloud Text-to-Speech API
Installation
You can install the package via composer:
You can publish the config file with:
Configuration
After publishing the configuration file, you can set your Google Cloud credentials and other settings in the config/laravel-google-text-to-speech.php file.
Published config file will look like this:
[!NOTE] If you are using Google Cloud Text-to-Speech API:
- Go to the Google Cloud Console to create and download your service account credentials with proper permissions for Text-to-Speech API.
- Save the downloaded JSON file and set its path in the config
cloud.credentialsfield.If you are using Gemini Text-to-Speech API:
- Go to Google Cloud Console and select the project where Gemini API is enabled (or create a project).
- Create a service account with the necessary roles to access Gemini API.
- Add a new key on the Keys tab, which will be used in the config
gemini.api_keyfield.
Usage
There are 2 drivers for Google Text-to-Speech API:
gemini: Uses Gemini Text-to-Speech API.cloud: Uses Google Cloud Text-to-Speech API.
Gemini Text-to-Speech API is the newer and more advanced API (premium voices), while Google Cloud Text-to-Speech API is the traditional API.
[!NOTE] You can set the driver in the config file so that the package uses the desired API automatically
(You need to set credentials/api_key, and api_endpoint accordingly in the config file for the selected driver)
Synthesize Text
This is an example of how to use the synthesizeText method:
For Gemini Text-to-Speech API:
$responsewill contain the synthesized audio content (bytes). it can be saved as an audio file as follows:
[!NOTE] Gemini Text-to-Speech API currently supports only .pcm audio format.
After saving the output as a
.pcmfile, you can convert it to other audio formats (like.wavor.mp3) using tools likeffmpeg.[!TIP] Check
GeminiVoiceDataclasses for more options.
For Cloud Text-to-Speech API:
$responsewill contain the synthesized audio content (bytes). it can be saved as an audio file as follows:
[!TIP] Check
CloudAudioConfigDataclasses for more options.
List Voices
This is an example of how to use the listVoices method:
$responsewill contain a list/array of available voices for the specified language code.
[!WARNING]
listVoicesmethod only works with Google Cloud Text-to-Speech API. It is not supported for Gemini Text-to-Speech API.
Contributing
Your contributions are welcome! If you'd like to improve this project, simply create a pull request with your changes. Your efforts help enhance its functionality and documentation.
If you find this project useful, please consider ⭐ it to show your support!
Authors
This project is created and maintained by Moe Mizrak.
License
Laravel Package Template is an open-sourced software licensed under the MIT license.
All versions of laravel-google-text-to-speech with dependencies
spatie/laravel-data Version ^4.17
google/cloud-text-to-speech Version ^2.6