TextToSpeech Accessibility
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.
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.
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.
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!

Hi!
I download the example and change the language to HUNGARIAN. The code is working but the special hungarian characters (like: “á” “é”) is not.
for example “á” -> silence
Do you have any idea, what i make wrong?
Thank you!
Blan
This issue has to do with the way the data is returned (a json string). Usually when I work with special characters with xml I’ll wrap everything within CDATA tags, however because google returns a json string without CDATA special characters like “á” “é” don’t appear to be coming through as they should. You could put a script between the google url and your swf that parses the return data into xml with CDATA tags. hope this helps.
Hi,
thank you for the class, it works perfectly in local, but when I put on my server it doesn’t work anymore…
What should I do for making work it online?
Thanks,
Gabriele
you’ll need to use a proxy, see: http://peteshand.net/blog/index.php/as3-text-to-speech-plus-proxy/
Hi there Pete, congrats for the awesome job, I have a question for you, could this class be used with other languages like brazilian portuguese or french…?
Regards…
Hey Andre. yep, absolutely. You just need to set the Lang property on your TextToSpeech object.
eg:
or you can import ps.GTranslate.Language and this will give you code hinting for all the supported languages.
eg:
Also if you haven’t already seen the other posts on google text to speech you can check them out here (although some of these examples might be out of date)