Due to a bug (?) in FreeTTS package the sample provided dosn't work for me. The code "synth = Central.createSynthesizer(null);" returns null. I guess this is because FreeTTS is unable to find the speech.properties file.
This is a workaround:
public static void main (String [] args)
{
try
{
SynthesizerModeDesc desc =
new SynthesizerModeDesc(null,
"general", /* use "time" or "general" */
Locale.US,
Boolean.FALSE,
null);
com.sun.speech.freetts.jsapi.FreeTTSEngineCentral central = new com.sun.speech.freetts.jsapi.FreeTTSEngineCentral();
EngineList list = central.createEngineList(desc);
if (list.size() > 0) {
EngineCreate creator = (EngineCreate) list.get(0);
synth = (Synthesizer) creator.createEngine();
}
if (synth == null) {
System.err.println("Cannot create synthesizer");
System.exit(1);
}
synth.allocate();
synth.resume();
}
catch (Exception e)
{
e.printStackTrace();
System.exit (0);
}
createGUI ().setVisible (true);
}
Regards,
Patrik |