Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
clarify minification stuff
  • Loading branch information
kripken committed Aug 2, 2011
1 parent f67ed24 commit d8bebc6
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 10 deletions.
11 changes: 9 additions & 2 deletions README.markdown
Expand Up @@ -17,6 +17,8 @@ Very simple! Do this:

`<script src="speak.js"></script>`

(and make sure you have speak.js where it will be found)

* Add a div with an audio element called 'audio' in your html body,

`<div id="audio"></div>`
Expand All @@ -27,11 +29,16 @@ Very simple! Do this:

See demo.html for an example use.

speak.js is the unminified version, speak.min.js is after being run through the Closure Compiler. You should probably use that one.


Building
--------

Run emscripten.sh inside src/. Note that you need to change the paths there.

That will generate speak.full.js, which is the unminified version. It is
recommended to minify that (for example, using the closure compiler). speak.js
in this repo is minified.

demo.full.html is the same as demo.html but uses speak.full.js. It is useful
for testing.

40 changes: 40 additions & 0 deletions demo.full.html
@@ -0,0 +1,40 @@
<html>
<title>Text-to-Speech on the Web</title>
<head>
<script>
// This demo is licensed under the GNU GPL.
</script>
<script src="speak.full.js"></script>
</head>
<body>
<h1>Text-To-Speech on the Web</h1>

<form onsubmit="speak(text.value); return false">
Text: <input type="text" name="text" size=50 value="Never gonna give, you, up."><input type="submit" value="Go!">
</form>
<hr>
<p>
This demo is 100% clientside JavaScript. It uses <a href="http://espeak.sourceforge.net/">eSpeak</a>, an open source
speech synthesizer, which was compiled from C++ to JavaScript using <a href="http://emscripten.org">Emscripten</a>.
Source code for this demo can be found <a href="espeak_src.tar.bz2">here</a>.
</p>

<p>
Browser requirements:
<ul>
<li><b>Typed arrays</b>. The eSpeak code is not portable to the extent that would be necessary to avoid using typed arrays.
(It should however be possible to rewrite small bits of eSpeak to fix that.)
This is present in Firefox and Chrome, but not IE, Safari or Opera.</li>
<li><b>Support for WAV audio in data URIs</b>. eSpeak's simplest form of output is a WAV file, and the easiest way to use
that is via a data URI. (It should however be possible to extract the raw audio directly by hacking eSpeak.)
This is present in Firefox, Safari and Opera, but not IE or Chrome.</li>
</ul>
So currently this demo will only work in Firefox. Help is welcome regarding the workarounds mentioned above
that will let it work elsewhere, we would like to develop this demo into a useful project for people to use around the web.
If you want that too, get in touch with us by any of the methods listed at the bottom of <a href="http://emscripten.org">this page</a>.
</p>

<div id="audio"></div>
</body>
</html>

17 changes: 9 additions & 8 deletions src/emscripten.sh
Expand Up @@ -3,17 +3,18 @@ RANLIB=/home/alon/Dev/emscripten/tools/emmaken.py AR=/home/alon/Dev/emscripten/t
echo "dis"
~/Dev/llvm-2.9/cbuild/bin/llvm-dis -show-annotations speak -o=speak.ll
echo "emscripten"
python /home/alon/Dev/emscripten/emscripten.py -O -s USE_TYPED_ARRAYS=2 -s ASSERTIONS=0 -s OPTIMIZE=1 -s RELOOP=0 speak.ll > espeak.raw.js
python /home/alon/Dev/emscripten/emscripten.py -O -s USE_TYPED_ARRAYS=2 -s ASSERTIONS=0 -s OPTIMIZE=1 -s RELOOP=1 speak.ll > espeak.raw.js
echo "bundling"
cat pre.js > ../speak.js
cat pre.js > ../speak.full.js
for filey in phontab phonindex phondata intonations en_dict
do
python ~/Dev/emscripten/tools/file2json.py ../espeak-data/$filey $filey >> ../speak.js
python ~/Dev/emscripten/tools/file2json.py ../espeak-data/$filey $filey >> ../speak.full.js
done
python ~/Dev/emscripten/tools/file2json.py ../espeak-data/voices/en/en-us en_us >> ../speak.js
cat espeak.raw.js >> ../speak.js
cat post.js >> ../speak.js
#~/Dev/mozilla-central/js/src/js -m speak.js -w wav.wav --path="/home/alon/Dev/espeak-1.45.04-source" "hello world"
#~/Dev/v8/d8 header.js speak.js footer.js
python ~/Dev/emscripten/tools/file2json.py ../espeak-data/voices/en/en-us en_us >> ../speak.full.js
cat espeak.raw.js >> ../speak.full.js
cat post.js >> ../speak.full.js
#~/Dev/mozilla-central/js/src/js -m speak.full.js -w wav.wav --path="/home/alon/Dev/espeak-1.45.04-source" "hello world"
#~/Dev/v8/d8 header.js speak.full.js footer.js
#gnome-sound-recorder wav.wav
#java -jar /home/alon/Dev/closure-compiler-read-only/build/compiler.jar --compilation_level SIMPLE_OPTIMIZATIONS --variable_map_output_file speak.vars --js speak.full.js --js_output_file speak.js

0 comments on commit d8bebc6

Please sign in to comment.