This discussion is archived
0 Replies Latest reply: Oct 28, 2009 12:53 PM by 843802 RSS

FreeTTS NullPointerException when using allocate()

843802 Newbie
Currently Being Moderated
I am just starting with the JSAPI using the FreeTTS implementation. As of right now, I just want to make the application functional. All I want to happen is for the program to speak "Hello World" as in the tutorial that I found. The problem is that, when I attempt to run the application, I receive a NullPointerException on the line with synth.allocate(). I have read that adding all the jar files in the lib folder of the FreeTTS 1.2.2 folder. I have done that and am getting no response. I am using Netbeans 6.7.1.
import javax.speech.*;
import javax.speech.synthesis.*;
import java.util.Locale;

public class TTS {

    public static void main(String[] args) {
        try {
            SynthesizerModeDesc desc = new SynthesizerModeDesc(Locale.ENGLISH);
            Synthesizer synth = Central.createSynthesizer(desc);
            synth.waitEngineState(Synthesizer.ALLOCATED);

            synth.allocate();
            synth.resume();

            synth.speakPlainText("Hello World", null);
            synth.waitEngineState(Synthesizer.QUEUE_EMPTY);

            synth.deallocate();
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}
Any help with this issue would be appreciated.