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();
}


I Agree



Flash Resolution-Week 3: Google Maps API + iPhone GPS Tracking

To build on my previous post about the Google Maps ActionScript API, I wanted to track the position of my iPhone in real time. I came across the site instamapper.com. After creating a free account with Instamapper and downloading their iPhone app from the Apple App Store, I was tracking my phone in no time. They have prebuilt maps that you can embed on your blog and even a Facebook application. Although I wanted to use my own map so I can have more control over the map. Instamapper has a simple little API that you can use to retrieve your information. A http call returns a string of all the data about your phone's location. Using a URLLoader to load in the request (http://www.instamapper.com/api?action=getPositions&key=584014439054448247) returns the data:

InstaMapper API v1.00
0071543339995,Demo car,1209252615,47.58822,-122.17969,25.0,27.7,349

The format of each record (seporated by commas) is as follows:

  1. Device key
  2. Device label
  3. Position timestamp in UTC (number of seconds since January 1, 1970)
  4. Latitude
  5. Longitude
  6. Altitude in meters
  7. Speed in meters / second
  8. Heading in degree

So using a split() method on the returned string, I could just parse the latitude and longitude coordinates and sent them to my Google map object. Here is a screen shot of my application. The only problem is that instamapper.com does not (yet) have a cross domain policy, which is not allowing the SWF on my server to access instamapper's server. Though it works just fine when run locally. So for now, this is just a proof of concept.



Augmented Reality

The term "Augmented Reality" is something that I'm sure we'll be hearing a lot more of within the next few years. Augmented reality (AR) is a field of computer research which deals with the combination of real-world and computer-generated data (virtual reality), where computer graphics objects are blended into real footage in real time.

The first application I came across that uses this is GE. This Flash app directs you to print out a piece of paper with a pattern on it, hold it in front of your web cam, and you see a virtual world unfold where the pattern is.

Here is another example on the iPhone via the Augmented Environments Lab blog.

http://www.youtube.com/watch?v=_0bitKDKdg0

Lee Brimelow also has a great video tutorial on creating an AR Flash app with Parervision3D.

This opens up a huge possibliity for interacting with applications and games. Imagine wearing a certian pattern on your shirt while standing in front of your favorite gaming console, which has a camera pointing back at you. But instead of seeing you on the screen, you see the game's character that you are now controlling. Now, I don't know if this technology is there yet, but I can imagine that its not far off.