0

我只想对这段代码使用 Freetts 测试,但出现错误:

ClassCastException:com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory 类无法转换为 com.sun.speech.freetts.VoiceDirectory 类(com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory 在加载程序 com.sun.speech.freetts.DynamicClassLoader @23bc24e9 的未命名模块;com.sun.speech.freetts.VoiceDirectory 在加载程序“app”的未命名模块中)

有什么问题?

我已经放了图书馆。

import com.sun.speech.freetts.VoiceManager;

public class  Voice {
    private String name;
    private com.sun.speech.freetts.Voice voice;

    public Voice(String name) {
        this.name = name;
        this.voice = VoiceManager.getInstance().getVoice(this.name);
        this.voice.allocate();
    }

    public void say(String something) {
        this.voice.speak(something);
    }

    public static void main(String[] args) {
       Voice voice = new Voice("kevin16");
       String say ="hi";
       voice.say(say);
    }
}
4

0 回答 0