UPDATE: October 1st, 2012
I noticed that the code doesn’t work anymore, since they’ve added a crossdomain reference and modified the API a bit, but a simple proxy should do the trick, check this blog for solution.
I’ve just discovered an ultra-simple way of converting text to speech utilizing an undocumented Google API code.
import flash.media.Sound;
import flash.net.URLRequest;
var _path:String = 'http://translate.google.com/translate_tts?q=';
var _sound:Sound = new Sound();
// all it takes is just to pass the words to the path
_sound.load(new URLRequest(_path+ 'hello world'));
_sound.addEventListener(Event.COMPLETE, soundLoaded);
function soundLoaded(e:Event):void
{
_sound.play();
_sound.removeEventListener(Event.COMPLETE, soundLoaded);
_sound = null;
}
It’s limited, yet the practical uses of it are endless.
Here’s a little demo.
Nice function, is there a way to put more text then the limit?
hey Chris, for the API it selves i haven’t tried any thing that is longer than the one i have in my demo, but I’m guessing yes, you can put something longer although i think it’ll use much more bandwidth and loads a bit longer as well.
hope that helps..