composer require google-free/google-speech-tts
$audioOutputDir = __DIR__ . '/audio';
$ttsClient = new \GoogleFree\TextToSpeech\Client($httpClient);
$ttsClient->setAudioOutputDir($audioOutputDir);
$speechFile = new \GoogleFree\TextToSpeech\SpeechFile('The freedom of speech', 'en-US');
$didSucceed = $ttsClient->downloadAudio($speechFile);
// now you should see an audio file in the '/audio' directory
-
git clone git@github.com:Gyvastis/google-speech-tts.git
-
composer install
-
php example.php
All available langauge tags can be found here.
This is an updated approach of AlboVieira.
As this is a very simple but still a wrapper over an existing service, use it at your own risk.