这是我的代码
import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;
public class FreeTTS {
private static final String VOICENAME_kevin = "kevin";
private String text; // string to speech
public FreeTTS(String text) {
this.text = text;
}
public void speak() {
Voice voice;
VoiceManager voiceManager = VoiceManager.getInstance();
voice = voiceManager.getVoice(VOICENAME_kevin);
voice.allocate();
voice.speak(text);
}
public static void main(String[] args) {
String text = "FreeTTS was written by the Sun Microsystems Laboratories "
+ "Speech Team and is based on CMU's Flite engine.";
FreeTTS freeTTS = new FreeTTS(text);
freeTTS.speak();
}
}
尽管我将freetts的lib文件夹包含到该项目中,但它在导入中给了“ com.sun.speech”一个错误。
任何帮助将不胜感激。
最佳答案
我遍历了您的代码,它需要freetts-1.0.jar
只需下载然后
将此jar添加到您的项目类路径中
或创建一个名为lib的新文件夹,然后将freetts-1.0.jar粘贴到该文件夹(即lib)中,然后添加该jar。
关于java - com.sun.speech.freetts中的错误。*,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20162523/