I am trying to make a text to speech program, but I always get this:
Exception in thread "main" java.lang.NullPointerException
at FreeTTS.main(FreeTTS.java:7)
Here is my code:
import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;
public class FreeTTS {
public static void main(String args[]) {
VoiceManager vm = VoiceManager.getInstance();
Voice voice = vm.getVoice("kevin16");
voice.allocate();
voice.speak("Hello World!");
voice.deallocate();
}
}
how can I fix it?