0

The following code shows a simple use of speech synthesis to speak the string "Hello World".

package helloworld;

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();
		}
	}
}

/* But if i run in Netbean7.0 than following is found .....
run:
java.lang.NullPointerException
at helloworld.HelloWorld.main(HelloWorld.java:15)
BUILD SUCCESSFUL (total time: 1 second)

How i can solve this problem ?
Please help me .

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Mamun13
0

I am really sorry to says that this is my first programm with speech synthesis . I cann't understand what do you mean by " installed any inplementation of the API " .
Please tall me step by step way to solve this error .
NB: HelloWorld package has include jsapi.jar in Libraries of Netbean7.0

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.