OK, so I'm wanting to mess around with Java's speech capabilities - see what can be done. I've found FreeTTS, and I grabbed the JSAPI.jar file out of their distribution. I stole a few HelloWorld programs from the
Java Speech API Programmer's Guide, put them into IDEA, added the JSAPI.jar as an external JAR library and hit "Run." On both programs I get a NullPointException when allocate() is called on the synthesizer and recogniser created by javax.speech.Central. The synthesis program is shown below. No syntax errors inside IDEA or Eclipse. When I try to compile from the command line, the compile succeeds, but at runtime I get a NoClassDefFoundError on javax.speech.EngineModeDesc, despite it being part of the included JAR.
The heck? Anyone got any ideas as to why this is happening? Can't find anything on Google.
TIA
import javax.speech.*;
import javax.speech.synthesis.*;
import java.util.Locale;
public class HelloWorld {
public static void main(String args[]) {
try {
// Create a synthesizer for English
Synthesizer synth = Central.createSynthesizer(
new SynthesizerModeDesc(Locale.ENGLISH));
// Get it ready to speak
synth.allocate();
synth.resume();
// Speak the "Hello world" string
synth.speakPlainText("Hello, world!", null);
// Wait till speaking is done
synth.waitEngineState(Synthesizer.QUEUE_EMPTY);
// Clean up
synth.deallocate();
} catch (Exception e) {
e.printStackTrace();
}
}
}