0

我想将 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();
4

0 回答 0