Free Text-to-Speech in Flash

There are several text-to-speech packages out there. But thanks to Google Translate, you can create a sort of "poor-man's" text-to-speech application in Flash. The method is a simple query string to the Google Translate service, which returns an MP3. Simply load that Mp3 into Flash, and voilà. The draw backs are that you only get on voice (although you can choose different languages which use an alternate accents) and you have a limit of 100 characters.

Check out the example and source code below.

import flash.events.MouseEvent;
import flash.media.Sound;
import flash.text.TextField;
import fl.controls.Button;
 
// stage instances
var input_txt:TextField;
var speak_btn:Button;
 
var speech:Sound;
var url:String = "http://translate.google.com/translate_tts?q=";
 
input_txt.maxChars = 100;
speak_btn.addEventListener(MouseEvent.CLICK, handleClick);
 
function handleClick(e:MouseEvent):void {
     speech= new Sound();
     speech.load(new URLRequest(url + input_txt.text));
     speech.play();
}


My 2010 Resolution Fail

Ok so, in the beginning of 2010 I made a New Years resolution that I would learn one new thing each week and blog about it. Like most resolutions, it went for three weeks and then failed miserably. Now I would normally look at this as a failed attempt to commit to learning. However, the reason that I'm not able to keep up with this is because I am just too damn busy. I'm 6 months into my new job at Neo-Pangea, and loving it. We are developing some really awesome Flash applications that push the limits and are just down right bitchin'. So it goes without saying that I "am" learning more and more as we continue to kick ass for our clients.



Awesome Tweening Class

I just have to mention how satisfied I am with the tween class that I have been using for the passed few months. For those who don't know, a tweening class is a custom set of ActionScript classes that allow you to animate any type of property in your application with pure code, no keyframes on the timeline. Jack Doyle of GreenSock has some great classes that does just that. It is the smallest filesize and most efficient tweening class I've worked with so far. Jack is constantly improving these classes. This week he just updated the sequencing capabilities with the TweenGroup class.

Below was created with a simple TweenGroup that is set to loop.

Here is a list of all the features for the classes.
http://blog.greensock.com/tweening-family-comparison