Pete Shand
  • Home
  • About
  • Contact
  • Showreel
Home » Text To Speech
Apr16 7

as3 Text To Speech plus proxy

Posted by Pete Shand in Actionscript, Text To Speech, Translation

A while back I wrote a post on a few as3 classes I wrote that would hook into googles text to speech engine (you can view the original post here). Unfortunately there was a few problems with the way it worked, first and foremost not all browsers handled the cross domain sound request the same, as in IE/Chrome bitched about cross domain policy files. secondly there were some issues around using special characters (non english character sets)

Get Adobe Flash player

I wasn’t using these classes in any commercial projects, so sadly these issues were never investigated, well that is until a chap by the name of Daniel Kazmer needed this type of functionality in one of his projects, I suggested looking into a proxy for the cross domain issues and that’s just what he did.

Click here to download the as3 text to speech classes as well as the proxy file Dan created (Note you’ll need php and curl installed to take advantage of the proxy).

While this is a step in the right direction it turns out there are still some issues surrounding special characters, but regardless thanks for your input Dan!

Read More
May13 6

TextToSpeech Accessibility

Posted by Pete Shand in Actionscript, Text To Speech

Get Adobe Flash player

I recently posted a TextToSpeech as3 interface class which you can view here. Basically you pass it a string and it will read it out loud.

Today I’ve added an easy way to increase the accessibility of your flash microsite without having to go through the whole project adding code to every button. Simply add the two lines below to your root document and this class will search through every display object and add rollover text to speech.

?View Code ACTIONSCRIPT
1
2
3
import ps.GText2Speech.Accessibility;
 
var accessibility:Accessibility = new Accessibility(this);



You can also specify to read the text on a click or rollout instead of the default rollover.

?View Code ACTIONSCRIPT
1
2
3
4
5
6
import ps.GText2Speech.Accessibility;
 
var accessibility:Accessibility = new Accessibility(this);
accessibility.Rollover = false;
accessibility.Click = true;
accessibility.Rollout = true;



In most cases there will probably be some textfields you want to ignore, so if you need to do this simply add the display object to the exclude list.

?View Code ACTIONSCRIPT
1
accessibility.exclude(mc_skip);



You can download the source and example files here.

If you fine any bugs or have any additional feature requests please post them below.
Enjoy!

Read More
May08 46

Actionscript Text To Speech

Posted by Pete Shand in Actionscript, Text To Speech

Ever wanted to add text to speech functionality to your Actionscript project?
Well now you can thanks to this cool little as3 class I wrote last night.

So how does it work?
Google hasn’t released an official API for their text to speech engine, however if you query: http://translate.google.com/translate_tts?tl=en&q=this%20is%20a%20test an mp3 will be produced which speaks whatever q equals. There is however a limit to how many characters will be accepted in one query. TextToSpeech.as gets around this limitation by splitting your request up into smaller more manageable parts and then requests them one at a time. TextToSpeech.as also fixes the delay between clips on playback by starting playback of the next segment just before the current one finishes.

Get Adobe Flash player

TextToSpeech.as simply bridges the gap between the Google text to speech engine and your as3 project. The example below imports TextToSpeech.as, loads a string (the first paragraph of this blog) and then plays it once the first segment has been converted and downloaded.

?View Code ACTIONSCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
import ps.GText2Speech.TextToSpeech;
import ps.GTranslate.Language;
 
textToSpeech = new TextToSpeech();
textToSpeech.Lang = Language.ENGLISH;
textToSpeech.addEventListener("FirstClipLoaded", beginPlaying);
textToSpeech.load('Ever wanted to add text to speech functionality to your Actionscript project? Well now you can thanks to Google and this awesome little as3 class I’ve written.');
 
function beginPlaying(event:Event):void
{
   textToSpeech.play();
}

Because TextToSpeech.as relies on the Google TextToSpeech engine it does mean that this could stop working in the future if Google decides to change or remove the URL. I guess the best way would be to actually do everything within actionscript, however this is easier said than done, so for the time being this is the best option we have.

You can download the source and example files here.

If anyone has additional feature requests please post them below.
Enjoy!

——————————————————
Update – Leading on from this post I’ve added a TextToSpeech accessibility class: Read More

——————————————————
Update – Seems to be a problem with the request within IE, not to sure what the problem is as I’m on a mac. I guess if you want to use this for a project it’d probably be a good idea to use a proxy on the same domain as your flash content.

Read More

Categories

  • 3D Flash
  • Actionscript
  • Design
  • Facebook
  • Flash
  • Javascript
  • Online Advertising
  • Photography
  • Recent Work
  • Text To Speech
  • Translation
  • Video

Recent Comments

  • Pete Shand on .MPO to Anaglphic or Stereo Pair JPG
  • Pete Shand on .MPO to Anaglphic or Stereo Pair JPG
  • Kyle on .MPO to Anaglphic or Stereo Pair JPG
  • Paul on Actionscript Text To Speech
  • Pete Shand on Actionscript Text To Speech

What I'm Doing...

  • RT I 2nd that @karlfreeman: Painful presentation at #fotb at the moment. Should've gone to monster projects and rewatch it again from their 2010-09-28
  • @ReDrUmNZ I'd leave it at home... ya going on holiday to get any from that shit in reply to ReDrUmNZ 2010-09-14
  • @ReDrUmNZ I can honestly say i haven't had any problems with CS5, stink 2 b u huh, lol in reply to ReDrUmNZ 2010-08-17
  • More updates...
Get Adobe Flash playerPlugin by wpburn.com wordpress themes

© 2011 Pete Shand | Designed by Elegant Themes | Powered by WordPress