Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
fixes for closure
- Loading branch information
Showing
5 changed files
with
62 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,70 @@ | ||
|
||
FS.ignorePermissions = true; | ||
FS.ignorePermissions = true; | ||
|
||
FS.createPath('/', 'espeak/espeak-data', true, false); | ||
[['config', config], ['phontab', phontab], ['phonindex', phonindex], ['phondata', phondata], ['intonations', intonations], ['en_dict', en_dict] /*, ['fr_dict', fr_dict] */].forEach(function(pair) { // commented-out code here is needed for French | ||
var id = pair[0]; | ||
var data = pair[1]; | ||
FS.createDataFile('/espeak/espeak-data', id, data, true, false); | ||
}); | ||
FS.createPath('/', 'espeak/espeak-data', true, false); | ||
[['config', config], ['phontab', phontab], ['phonindex', phonindex], ['phondata', phondata], ['intonations', intonations], ['en_dict', en_dict] /*, ['fr_dict', fr_dict] */].forEach(function(pair) { // commented-out code here is needed for French | ||
var id = pair[0]; | ||
var data = pair[1]; | ||
FS.createDataFile('/espeak/espeak-data', id, data, true, false); | ||
}); | ||
|
||
//FS.createPath('/', 'espeak/espeak-data/voices', true, false); // Needed for French | ||
//FS.createDataFile('/espeak/espeak-data/voices', 'fr', fr, true, false); // Needed for French | ||
//FS.createPath('/', 'espeak/espeak-data/voices', true, false); // Needed for French | ||
//FS.createDataFile('/espeak/espeak-data/voices', 'fr', fr, true, false); // Needed for French | ||
|
||
FS.createPath('/', 'espeak/espeak-data/voices/en', true, false); | ||
FS.createDataFile('/espeak/espeak-data/voices/en', 'en-us', en_us, true, false); | ||
FS.createPath('/', 'espeak/espeak-data/voices/en', true, false); | ||
FS.createDataFile('/espeak/espeak-data/voices/en', 'en-us', en_us, true, false); | ||
|
||
FS.root.write = true; | ||
FS.root.write = true; | ||
|
||
FS.ignorePermissions = false; | ||
FS.ignorePermissions = false; | ||
|
||
args = args || {}; | ||
Module.arguments = [ | ||
'-w', 'wav.wav', | ||
// options | ||
'-a', args.amplitude ? String(args.amplitude) : '100', | ||
'-g', args.wordgap ? String(args.wordgap) : '0', // XXX | ||
'-p', args.pitch ? String(args.pitch) : '50', | ||
'-s', args.speed ? String(args.speed) : '175', | ||
'-v', args.voice ? String(args.voice) : 'en/en-us', | ||
// end options | ||
'--path=/espeak', | ||
text | ||
]; | ||
var args = this['args'] || {}; | ||
Module.arguments = [ | ||
'-w', 'wav.wav', | ||
// options | ||
'-a', args['amplitude'] ? String(args['amplitude']) : '100', | ||
'-g', args['wordgap'] ? String(args['wordgap']) : '0', // XXX | ||
'-p', args['pitch'] ? String(args['pitch']) : '50', | ||
'-s', args['speed'] ? String(args['speed']) : '175', | ||
'-v', args['voice'] ? String(args['voice']) : 'en/en-us', | ||
// end options | ||
'--path=/espeak', | ||
this['text'] | ||
]; | ||
|
||
run(); | ||
run(); | ||
|
||
var wav = FS.root.contents['wav.wav'].contents; | ||
var wav = FS.root.contents['wav.wav'].contents; | ||
|
||
function encode64(data) { | ||
var BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; | ||
var PAD = '='; | ||
var ret = ''; | ||
var leftchar = 0; | ||
var leftbits = 0; | ||
for (var i = 0; i < data.length; i++) { | ||
leftchar = (leftchar << 8) | data[i]; | ||
leftbits += 8; | ||
while (leftbits >= 6) { | ||
var curr = (leftchar >> (leftbits-6)) & 0x3f; | ||
leftbits -= 6; | ||
ret += BASE[curr]; | ||
} | ||
function encode64(data) { | ||
var BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; | ||
var PAD = '='; | ||
var ret = ''; | ||
var leftchar = 0; | ||
var leftbits = 0; | ||
for (var i = 0; i < data.length; i++) { | ||
leftchar = (leftchar << 8) | data[i]; | ||
leftbits += 8; | ||
while (leftbits >= 6) { | ||
var curr = (leftchar >> (leftbits-6)) & 0x3f; | ||
leftbits -= 6; | ||
ret += BASE[curr]; | ||
} | ||
if (leftbits == 2) { | ||
ret += BASE[(leftchar&3) << 4]; | ||
ret += PAD + PAD; | ||
} else if (leftbits == 4) { | ||
ret += BASE[(leftchar&0xf) << 2]; | ||
ret += PAD; | ||
} | ||
return ret; | ||
} | ||
|
||
for (var i = 0; i < wav.length; i++) { | ||
wav[i] = unSign(wav[i], 8); | ||
if (leftbits == 2) { | ||
ret += BASE[(leftchar&3) << 4]; | ||
ret += PAD + PAD; | ||
} else if (leftbits == 4) { | ||
ret += BASE[(leftchar&0xf) << 2]; | ||
ret += PAD; | ||
} | ||
return ret; | ||
} | ||
|
||
document.getElementById("audio").innerHTML=("<audio id=\"player\" src=\"data:audio/x-wav;base64,"+encode64(wav)+"\">"); | ||
document.getElementById("player").play(); | ||
for (var i = 0; i < wav.length; i++) { | ||
wav[i] = unSign(wav[i], 8); | ||
} | ||
|
||
this['speak'] = speak; // for closure compiler | ||
document.getElementById("audio").innerHTML=("<audio id=\"player\" src=\"data:audio/x-wav;base64,"+encode64(wav)+"\">"); | ||
document.getElementById("player").play(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
|
||
{{{ FILES }}} | ||
|
||
function speak(text, args) { | ||
var Module = {}; | ||
Module['noInitialRun'] = true; | ||
|
||
var Module = { | ||
noInitialRun: true | ||
}; | ||
{{{ FILES }}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
return this.speak; | ||
}).call({}); | ||
}).call({ text: text, args: args }); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
var speak = (function() { | ||
// eSpeak and other code here are under the GNU GPL. | ||
// eSpeak and other code here are under the GNU GPL. | ||
function speak(text, args) { | ||
(function() { | ||
|