I got this result and I can't explain.
Exception in thread "main" java.lang.VerifyError: (class: javax/speech/Central, method: createRecognizer signature: (Ljavax/speech/EngineModeDesc;)Ljavax/speech/recognition/Recognizer;) Incompatible object argument for function call
at enad.trainings.Hello.main(Hello.java:31)
Line 31
is:
Synthesizer synth = Central.createSynthesizer(new SynthesizerModeDesc(Locale.ENGLISH));
I tried to search on google but it was not enough.
I wonder why the message error is about "Recognizer" while I'm using "Synthesizer".
enad.trainings
is a package that I created to test my code.
I'm working on Eclipse.
There is my code : package enad.trainings;
import java.util.Locale;
import javax.speech.Central;
import javax.speech.synthesis.Synthesizer;
import javax.speech.synthesis.SynthesizerModeDesc;
public class Hello {
public static void main(String[] args) {
try {
// Create a synthesizer for English
// Synthesizer synth = Central.createSynthesizer(new
// SynthesizerModeDesc(Locale.ENGLISH));
Synthesizer synth = Central.createSynthesizer(new SynthesizerModeDesc(Locale.ENGLISH));
// Get it ready to speak
synth.allocate();
synth.resume();
// Speak the "Hello World" string
synth.speak("Hello, world!", null);
// Wait till speaking is done
synth.waitEngineState(Synthesizer.QUEUE_EMPTY);
// Clean up
synth.deallocate();
} catch (Exception e) {
e.printStackTrace();
}
}
}