gpt4 book ai didi

java - com.sun.speech.freetts 中的错误。*

转载 作者:太空宇宙 更新时间:2023-11-04 15:23:14 26 4
gpt4 key购买 nike

这是我的代码

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com