Create a Flash Speech Synthesizer - Repeat the Sound
(Page 3 of 5 )
In the earlier groovyLoop.fla listing, a sound with the linkage identifier groovy is attached to the Sound instance myLoop. When the current sound completes playing, the onSoundComplete event invokes the nextSound( ) function, which sets the sound going again. Well, so what? Surely something like the following can accomplish the same thing:
myLoop = new Sound(this);
myLoop.attachSound("groovy");
myLoop.start(0, 1000);
Here we are using theSound.start( )method to cause our groovy sound to repeat 1000 times, more than long enough for most people to agree that our sound goes on forever.
The magic of onSoundComplete is that it is dynamic; you can change the sound on the fly to create things like sound mixing boards, because the callback function (in this case nextSound( ) ) can choose a different sound to start at the end of the current one. You can thus create dynamic sound tracks on which the sound loops are changed interactively or based on other events. We won’t look too deeply at that route here because it’s a standard usage and not part of the hack. Instead, let’s create a hack using a novel application that is fundamentally the same process.
Speech and Flash
When I first learned about onSoundComplete, I was also looking at accessibility and screen readers (plugins that the visually impaired use to convert web content into an audio speech stream). They are really cool, but they weigh in at more than 10 MB. Way back when we were all playing around with Commodore 64s and Atari consoles, speech could be created in about 32 KB. The trick was using a set of individual phonetic sounds called allophones, such as the “ou” in “you” and the “th” in “the.” I got to thinking that the code that created speech in the old 64 KB computers must have spliced all these tiny allophones together using something like onSoundComplete. More to the point, I was pretty sure it shouldn’t take 10 MB to do it, and that was the thing driving me to create this hack.
Although few people have the old 8-bit computer hardware lying around anymore, you can find numerous software emulators. Searching for “8-bit emulation” or “8-bit emulation allophone” in my search engine of choice (http://vivisimo.com) brings up a large number of emulator home pages.
Many of these emulators are capable of emulating speech synthesizer hardware that was available for the emulated systems.
 | If you've enjoyed what you've seen here, or to get more information, click on the "Buy the book!" graphic. Pick up a copy today!
Visit the O'Reilly Network http://www.oreillynet.com for more online content. |
Next: Phonetic Speech Synthesizer >>
More Flash Articles
More By O'Reilly Media