(1 minute read)
I decided to spend a few hours packaging up Weston's code as a re-usable library and here it is - https://github.com/hiddentao/google-tts. It's small (< 1KB minified and gzipped), supports 42 languages, and plays back the audio using the HTML5 Audio tag (just as Weston's example does).
Note: Audio playback in the browser will only work when running the script locally as Google's server only returns audio if you can prevent the browser from sending the Referrer HTTP Header to their server. If you want to add background playback to your online site perhaps SoundManager will do the trick (I haven't tested this).