Tag Archives: Text-To-Speech

Google Text-To-Speech

[8th Feb 2016] Note: this article is now obsolete, please check my newer article on Voice RSS


For some time I was using Google’s free Text-To-Speech  which provides a very simple way of converting text into speech:

http://translate.google.com/translate_tts?tl=en&q=Hello+world!

This enabled me to be greeted each morning with the weather forecast for the day.

However early August Google changed their website and forced users to enter a captcha to stop automated access, with the message “Our systems have detected unusual traffic from your computer network. This page checks to see if it’s really you sending the requests, and not a robot.“.

Seeing as I was using this in bash / python scripts, TTS would no longer work.

While looking for alternative (free) solutions, I tried various TTS solutions including epeak, festival, pico2wave, and Mbrola voices, but it was far off the quality provided by Google’s TTS engine.

Anyhow, not giving up, and after a lot of digging, I found the solution, I just had to add more parameters to Google URL. I’ve added the new link below with the new parameter in bold below. Also note the revised parameter for the translated language:

http://translate.google.com/translate_tts?ie=UTF-8&tl=en_GB&total=1&idx=0&client=t&q=Hello+world!

Now to call this from a bash script, use the below commands:

wget -q -U "Mozilla/5.0" -O output.mp3 "http://translate.google.com/translate_tts?ie=UTF-8&tl=en_GB&total=1&idx=0&client=t&q=Hello+World!"
mpg123 -q output.mp3

Notes:

  • Google will not accept access unless it thinks it’s a browser, to we have to use wget to output the sound into an mp3 using the -U “Mozilla/5.0” command.
  • Google has a limit of 100 characters per request

Now all I have to do in DomotiGa is to create an event triggered on a movement sensor with a condition based on hour of the day (typically 04:00 – 12:00), ensuring it will only run once in a set period (8h). This way, as soon as I enter the living room in the morning, I get greeted with the weather forecast for the day 😎
I use a free wunderground account to extract weather data from an xml file and achieve the above.