Topic: JS1K Speech Synthesizer Pages that link to <a href="https://ozoneasylum.com/backlink?for=32561" title="Pages that link to Topic: JS1K Speech Synthesizer" rel="nofollow" >Topic: JS1K Speech Synthesizer\

 
Author Thread
poi
Paranoid (IV) Inmate

From: Norway
Insane since: Jun 2002

IP logged posted posted 03-16-2012 20:44 Edit Quote

Ahoy! Long time no see... I drop by every now and then to see how's the asylum going.

You all know I'm crazy about JavaScript and size optimization. You probably also heard the JS1k contests. This contest gives you a shim HTML5 page with a canvas and 3 global variables to access the body, the canvas and its 2D context, and you have 1024 bytes of JavaScript to kick ass. No external resources, external API call, nada allowed!

JS1K#4 closed recently and the results are expected at JSConf US, on April 2 & 3.
This time the contest collided with our long awaited vacations but I definitely wanted to enter. The optional theme was "love", also Audio was game this time. Of course there was tons of flying hearts and flowers and yaddi blah, and some entries featured a little melody and simple sound effects.

But, no heavy 3D, FPS game, particle systems, flying hearts and flowers from me this time. Audio was ON and I had to make a Speech Synthesizer in 1K of JavaScript.

It's a simple formant based synthesizer that speaks whole sentences AND as you type. This puppy supports 25 sounds/phonemes.

I hope this zero polys and zero shaders* entry will catch people's eye^Wears.



(Edited by poi on 03-16-2012 20:44)

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

IP logged posted posted 03-17-2012 12:02 Edit Quote

would love to try it - only I get a 404 on your link?

NoJive
Maniac (V) Inmate

From: The Land of one Headlight on.
Insane since: May 2001

IP logged posted posted 03-17-2012 16:00 Edit Quote

I grabbed this from his twitter feed

"made it to the JavaScript Weekly newsletter. Next stop:"

but I can't get it to work.... but what do I know. -_Q


http://js1k.com/2012-love/demo/1274

___________________________________________________________________________
"It doesn?t matter to business, if cannibalism were legal, we would all be in cans."

poi
Paranoid (IV) Inmate

From: Norway
Insane since: Jun 2002

IP logged posted posted 03-17-2012 18:47 Edit Quote

Go me! I gave the wrong URL. Here's the correct URL of the JS1k Speech Synthesizer

I could only test on Windows. It works perfectly fine in Opera, Firefox and Chrome.
Safari was throwing an exception on new Audio(...) can you say spec violation ?

The demo page generates and speaks the default sentence right away. You can edit the giant text input featuring the default sentence. The synth will play a sound for each keypress and will generate and speak the whole text upon pressing ENTER.





(Edited by poi on 03-17-2012 18:50)

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

IP logged posted posted 03-18-2012 15:44 Edit Quote

amazing. Even though the focus is on the synthesizer, not the speech.

Can't quite say that the 1k limit makes the code more readable .
Would you elaborate about the method you use? The tuples per character look so very short
for coding waveforms..., but then I have no clue about this at all.

poi
Paranoid (IV) Inmate

From: Norway
Insane since: Jun 2002

IP logged posted posted 03-19-2012 07:34 Edit Quote

Thanks.
What do you mean by "The tuples per character look so very short for coding waveforms" ?

The synth + player is basically an optimized version of my Music Synth in 140bytes + player: The sounds are generated as an 8bits mono 8Khz WAVE PCM file, fed to a new Audio element ( as a data: URI ) that I play right away. Being 8bits mono, means that only one byte is needed per sample of the sound, and being 8Khz means that 8000 bytes are needed to make 1s of sound. Pretty basic math

The formant part, I ported to JS and optimized Tiny Speech Synth by Stepanov Andrey.

To fit in 1k I had to use 2 formant filters instead of 3 thus decreasing the size of the data and the quality of the speech. Also I ditched support for plosive ( overlapping ) sounds thus greatly simplifying the synth and allowing me to synthesize the speech in a single pass.

Hope that clarifies a few things.



(Edited by poi on 03-19-2012 07:38)

Tao
Maniac (V) Inmate

From: The Pool Of Life
Insane since: Nov 2003

IP logged posted posted 03-20-2012 04:02 Edit Quote

It's alive!!! Good stuff po1

Arthurio
Paranoid (IV) Inmate

From: cell 3736
Insane since: Jul 2003

IP logged posted posted 03-21-2012 17:34 Edit Quote

Very cool once again poi

poi
Paranoid (IV) Inmate

From: Norway
Insane since: Jun 2002

IP logged posted posted 03-22-2012 21:23 Edit Quote

Thanks.

I just tweaked the code, switched to my experimental packer and made the Audio element visible, thus adding support for volume setting/pause/stop/replay and sound export in over 100bytes less than the initial release.



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu