espeak_SetSynthCallback(NULL); | espeak_SetSynthCallback(NULL); | ||||
} | } | ||||
void set_voice( | |||||
long set_voice( | |||||
const char* aName, | const char* aName, | ||||
const char* aLang, | |||||
const char* aLang=NULL, | |||||
unsigned char aGender=0, | unsigned char aGender=0, | ||||
unsigned char aAge=0, | unsigned char aAge=0, | ||||
unsigned char aVariant = 0 | unsigned char aVariant = 0 | ||||
) { | ) { | ||||
espeak_VOICE props = { 0 }; | |||||
props.name = aName; | |||||
props.languages = aLang; | |||||
props.gender = aGender; | |||||
props.age = aAge; | |||||
props.variant = aVariant; | |||||
long result = 0; | |||||
if (aLang || aGender || aAge || aVariant) { | |||||
espeak_VOICE props = { 0 }; | |||||
props.name = aName; | |||||
props.languages = aLang; | |||||
props.gender = aGender; | |||||
props.age = aAge; | |||||
props.variant = aVariant; | |||||
result = espeak_SetVoiceByProperties(&props); | |||||
} else { | |||||
result = espeak_SetVoiceByName(aName); | |||||
} | |||||
// This way we don't need to allocate the name/lang strings to the heap. | // This way we don't need to allocate the name/lang strings to the heap. | ||||
// Instead, we store the actual global voice. | // Instead, we store the actual global voice. | ||||
espeak_SetVoiceByProperties(&props); | |||||
current_voice = espeak_GetCurrentVoice(); | current_voice = espeak_GetCurrentVoice(); | ||||
return result; | |||||
} | } | ||||
int getSizeOfEventStruct_() { | int getSizeOfEventStruct_() { |
void eSpeakNGWorker(); | void eSpeakNGWorker(); | ||||
void synth_(DOMString aText, VoidPtr aCallback); | void synth_(DOMString aText, VoidPtr aCallback); | ||||
long getSizeOfEventStruct_(); | long getSizeOfEventStruct_(); | ||||
void set_voice(DOMString aName, DOMString aLang, optional octet gender=0, optional octet age=0, optional octet aVariant=0); | |||||
long set_voice(DOMString aName, DOMString aLang, optional octet gender=0, optional octet age=0, optional octet aVariant=0); | |||||
[Const] attribute espeak_VOICE[] voices; | [Const] attribute espeak_VOICE[] voices; | ||||
readonly attribute long samplerate; | readonly attribute long samplerate; | ||||
attribute long rate; | attribute long rate; |
tts.set_pitch(Number(document.getElementById('pitch').value)); | tts.set_pitch(Number(document.getElementById('pitch').value)); | ||||
console.log(' Setting pitch... done'); | console.log(' Setting pitch... done'); | ||||
console.log(' Setting voice...'); | console.log(' Setting voice...'); | ||||
tts.set_voice.apply(tts, (document.getElementById('voice').value.split(','))); | |||||
tts.set_voice(document.getElementById('voice').value); | |||||
console.log(' Setting voice... done'); | console.log(' Setting voice... done'); | ||||
var now = Date.now(); | var now = Date.now(); | ||||
var sel = document.getElementById('voice'); | var sel = document.getElementById('voice'); | ||||
var index = 0; | var index = 0; | ||||
for (voice of result) { | for (voice of result) { | ||||
for (lang of voice.languages) { | |||||
var opt = document.createElement('option'); | |||||
opt.text = voice.name + ' (' + lang.name + ')'; | |||||
opt.value = [voice.name, lang.name]; | |||||
console.log('Adding voice: ' + opt.text); | |||||
sel.add(opt); | |||||
if (voice.name === 'default') { | |||||
opt.id = 'default-voice'; | |||||
opt.selected = true; | |||||
} | |||||
var opt = document.createElement('option'); | |||||
var languages = voice.languages.map(function(lang) { | |||||
return lang.name; | |||||
}).join(", "); | |||||
opt.text = voice.name + ' (' + languages + ')'; | |||||
opt.value = voice.identifier; | |||||
console.log('Adding voice: ' + opt.text); | |||||
sel.add(opt); | |||||
if (voice.name === 'default') { | |||||
opt.id = 'default-voice'; | |||||
opt.selected = true; | |||||
} | } | ||||
} | } | ||||
console.log('Leaving cb2'); | console.log('Leaving cb2'); |