Google text-to-speech in mp3 format

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.

What Others Think

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?

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"

What do you think?

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.

Similar 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.