*
* @return an engineList containing matching engines, or null if
* no matching engines are found
*/
public EngineList createEngineList(EngineModeDesc require) {
EngineList el = new EngineList();
com.sun.speech.freetts.VoiceManager voiceManager =
com.sun.speech.freetts.VoiceManager.getInstance();
com.sun.speech.freetts.Voice[] voices = voiceManager.getVoices();
// We want to get all combinations of domains and locales
Vector domainLocaleVector = new Vector();
for (int i = 0; i < voices.length; i++) {
DomainLocale dl =
new DomainLocale(voices[i].getDomain(), voices[i].getLocale());
DomainLocale dlentry = (DomainLocale)
getItem(domainLocaleVector, dl);
if (dlentry == null) {
domainLocaleVector.add(dl);
dlentry = dl;
}
dlentry.addVoice(voices[i]);
}
// build list of SynthesizerModeDesc's for each domain/locale
// combination
for (int i = 0; i < domainLocaleVector.size(); i++) {
DomainLocale dl = (DomainLocale) domainLocaleVector.get(i);
FreeTTSSynthesizerModeDesc desc = new
FreeTTSSynthesizerModeDesc("FreeTTS "
+ dl.getLocale().toString() + " " + dl.getDomain()
+ " synthesizer", dl.getDomain(), dl.getLocale());
// iterate through the voices in a different order
voices = dl.getVoices();
for (int j = 0; j < voices.length; j++) {
FreeTTSVoice jsapiVoice = new FreeTTSVoice(voices[j], null);
desc.addVoice(jsapiVoice);
}
if (require == null || desc.match(require)) {
try {
desc.validate();
el.addElement(desc);
} catch (ValidationException ve) {
System.err.println(ve.getMessage());
}
}
}
if (el.size() == 0) {
el = null;
}
return el;
}