0

i use speech synthesis javax.speech.synthesis for the first time
my program is simple that's say string "hello world"
but that not work and give me that Exception:

java.lang.NullPointerException
at soundreal.HelloWorld.main(HelloWorld.java:20)

and i don't know what that mean help plz

package soundreal;

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();
		}
	}
}
2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by stultuske
0

you're getting a nullpointerexception somewhere on line 20, but since there's no code on line 20...
I assume there's a problem in your use of the Synthesizer class, but since I've never seen it, don't know which one.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.