Using Google Text to Speech API – PHP

Google offers an undocumented text to speech API that help you transform text into voice. You can see a live demo at ctrlq.org/listen.

The following snippet of PHP code is responsible for the conversion while the MP3 files are cached to reduce requests to Google Translation servers.

Google Text to Speech – Command Line

You can also convert any piece of text to MP3 files from the command line using the wget or CURL command. Remember that the value of “q” parameter should have less than 100 characters else the Google Translate TTS API will throw an error.