Google text-to-speech in mp3 format

wget -q -U Mozilla -O output.mp3 "http://translate.google.com/translate_tts?ie=UTF-8&tl=en&q=hello+world
EDIT: command updated to support accented characters! Works in any of 58 google supported languages (some sound like crap, english is the best IMO). You get a mp3 file containing your query in spoken language. There is a limit of 100 characters for the "q" parameter, so be careful. The "tl" parameter contains target language.

10 Alternatives + Submit Alt

What Others Think

Wow, I could spend all afternoon listening to my name in different European accents :-)
flatcap · 396 weeks and 3 days ago
I tried this with Vietnamese, which I enter using unicode on a text editor and paste into the command line. However, I get nonsense back in the mp3 file. My command: wget -q -U Mozilla -O output.mp3 " It plays fine in the browser, which converts the URL: http://translate.google.com/translate_tts?tl=vi&q=%C4%90o%C3%A0n However, when I paste this url in the command line, I still get giberish: wget -q -U Mozilla -O output.mp3 " Any suggestions?
vinhdizzo · 396 weeks and 3 days ago
I can't seem to get it to work, too. I guess it is an issue with wget? http://savannah.gnu.org/bugs/index.php?20863 Maybe curl will work?
sairon · 396 weeks and 3 days ago
You could try piping the desired text into iconv to convert it to UTF-8 and only after that pipi the text into wget.
sairon · 396 weeks and 3 days ago
I tried piping to iconv: no go. curl also doesn't work.
vinhdizzo · 396 weeks and 3 days ago
it works great, i change it to function ### usage: texttospeach en hello+world texttospeach() { wget -q -U Mozilla -O output.mp3 " }
chmurli · 396 weeks and 3 days ago
We now can play the sound live without the need to save the mp3 file before with a bash function ( a bash builtin replace all spaces by the + caracter ) : say() { curl -s -A "Mozilla/5.0" "http://translate.google.com/translate_tts?tl=en&q=${@// /+}" | play -t mp3 -; } say "hello world"
sputnick · 394 weeks and 3 days ago
Note on the previous command : requires sox
sputnick · 394 weeks and 3 days ago
I've written a small ash shell script which can handle text flowing from a pipe and also gives you a warning when you exceed the 100-character limit. http://saironiq.blogspot.com/2011/03/google-text-to-speech-api.html
sairon · 394 weeks and 3 days ago
I use wget with Google Translate to send sound to my Airport Express device: http://www.geekytidbits.com/2011/05/text-to-speech-through-airtunes/
bradyholt · 382 weeks and 6 days ago
Are there alternative voices? Like male / female?
jesuisbenjamin · 315 weeks and 5 days ago
AFAIK there are no alternative voices
sairon · 315 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: