Как исправить ошибку 'classcastexception' с помощью Freetts - PullRequest
0 голосов
/ 18 июня 2019

Я просто хочу использовать тестирование 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);
    }
}
...