我正在尝试制作一个文本到语音程序,但我总是得到这个:
Exception in thread "main" java.lang.NullPointerException
at FreeTTS.main(FreeTTS.java:7)
这是我的代码:
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();
}
}
我该如何解决?