Simple Java Speech API program always gives a null pointer exception on synthesizer.allocate()...why?? how can i use system voice in my java program using JSAPI ?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Simple Java Speech API program always gives a null pointer exception on synthesizer.allocate()...why?? how can i use system voice in my java program using JSAPI ?
Can you post a small program that compiles, execute and shows the problems.
Also copy the full text of the error messages and post it here.
If you don't understand my answer, don't ignore it, ask a question.
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();
}
}
}
error.....
java.lang.NullPointerException
at HelloWorld.main(HelloWorld.java:22)
Where did you get the javax.speech package you are using?
If you don't understand my answer, don't ignore it, ask a question.