我想将JTextArea中的文本转换为语音,但我似乎在同一行继续收到错误。
Voice voice;
VoiceManager vm = VoiceManager.getInstance();
voice = vm.getVoice(VOICENAME);
voice.allocate();
try{
voice.speak(voice_txt.getText());
}
catch (Exception e){
JOptionPane.showMessageDialog(rootPane, e);}
这是我不断得到的错误
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at FrameTextToSpeech.jButton1ActionPerformed(FrameTextToSpeech.java:75)
错误指向此行
voice.allocate();