- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试在我的java程序中使用FreeTTS(来自 https://freetts.sourceforge.io/docs/index.php ),但收到此错误: java.lang.ClassCastException: com.sun.speech.freetts.en.us.cmu_time_awb.AlanVoiceDirectory 不能转换为 com.sun.speech.freetts.VoiceDirectory
我尝试将免费 TTS jar 文件重新添加到我的项目中,这是我的代码:
import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;
public class TextToSpeech {
//String voiceName = "kevin16";
VoiceManager freeVM;
Voice voice;
public TextToSpeech(String words) {
freeVM = VoiceManager.getInstance();
voice = VoiceManager.getInstance().getVoice("kevin16");
if (voice != null) {
voice.allocate();//Allocating Voice
}
try {
voice.setRate(190);//Setting the rate of the voice
voice.setPitch(150);//Setting the Pitch of the voice
voice.setVolume(3);//Setting the volume of the voice
SpeakText(words);// Calling speak() method
} catch (Exception e1) {
e1.printStackTrace();
}
}
public void SpeakText(String words) {
voice.speak(words);
}
我从另一个类中调用 TextToSpeech
构造函数,如下所示:
new TextToSpeech("Hello World");
非常感谢任何帮助或建议!
最佳答案
像这样更改 TextToSpeech 构造函数:
public TextToSpeech(String words) {
System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory");
voice = VoiceManager.getInstance().getVoice("kevin16");
if (voice != null) {
voice.allocate();// Allocating Voice
try {
voice.setRate(190);// Setting the rate of the voice
voice.setPitch(150);// Setting the Pitch of the voice
voice.setVolume(3);// Setting the volume of the voice
SpeakText(words);// Calling speak() method
} catch (Exception e1) {
e1.printStackTrace();
}
} else {
throw new IllegalStateException("Cannot find voice: kevin16");
}
}
这个想法是指示 freetts 使用 com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory
类而不是 AlanVoiceDirectory
类。
关于java - 如何修复错误 "cannot be cast to com.sun.speech.freetts.VoiceDirectory"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53008424/
我正在编写一个使用 Java 语音 API 和 FreeTTS 的应用程序。当我从 Netbeans IDE 运行该应用程序时,该应用程序工作正常,但是当我尝试从本地计算机或其他计算机上的 jar 文
我在我的 java 应用程序中使用了 Freetts.jar 文件来公布 token 号。我的应用程序在我的笔记本电脑上运行良好,但在我的带有外部扬声器的台式机上无法运行。我得到一个空指针异常。注意:
我正在尝试使用 FreeTTS,这是代码: import com.sun.speech.freetts.Voice; import com.sun.speech.freetts.VoiceManage
我写了一个小程序,应该用 Java 简单地进行文本到语音的转换。 我的类(class)是这样的: import com.sun.speech.freetts.Voice; import com.sun
当我尝试使用 FreeTTS 库时,出现错误: Could not validate any MBROLA voices at Some/Location/That/IThought/Held/mbr
我可以使用freetts吗?做一些像语音到文本的转换? 我需要从笔记本电脑的音频输入中检测特定的声音,我可以通过 freetts 来完成吗?在 Java 中? 最佳答案 不,请参阅 freetts F
我正在尝试将 freetts 用于一个简单的 java 应用程序,但我遇到了一个问题,谁能告诉我如何将从文本转换为语音的输出语音保存到程序中的 wave 文件中。我想通过代码来完成。 这是随示例提供的
我正在从事语音识别项目,因此我需要拥有超过数千个单词的音频文件。为了在 FreeTTS 中使用 Mbrola 语音,我已正确完成所有操作,但我只能使用 us1,us2,us3。它没有识别任何其他声音。
这个问题已经有答案了: What is a NullPointerException, and how do I fix it? (12 个回答) 已关闭 5 年前。 我正在尝试制作一个文本转语音程序
我是 FreeTTS 新手,这是我的第一个程序。以下程序只是读出传递的字符串。 如果这很重要的话,我正在使用 Linux Mint 32 位。但是我一天前在我的 Windows 计算机上提取了 jsa
我正在使用 HTML 和 JSP 构建一个 Web 应用程序。提供的功能之一是将一些文本转换为语音。在netbeans中,我创建了一个Java项目,该项目包含一个提供语音任务的Java小程序,该小程序
我正在用 Java 运行一个程序,我在其中使用 FreeTTS Voices,我想要的是改变声音。当我运行它显示的程序时: "System property "mbrola.base" is unde
我正在使用 freeTTS 说出一些文本,在后台我想要一个动画 gif 继续播放当我尝试这样做时:一旦声音开始说话,背景中的图像就会被挂起,即使我将其保留在其他 JFrame 中......并且在语音
首先,如果重要的话,我会使用 Ubuntu linux。 我有一个基于 FreeTTS 和 JSAPI(Java Speech API)的简单项目想法 我已经下载并解压了 FreeTTS 并运行了他们
这是我的代码 import com.sun.speech.freetts.Voice; import com.sun.speech.freetts.VoiceManager; public cla
我正在使用 Java 6 运行 Ubuntu 10.10,但无法让 FreeTTS 输出任何音频。我现在已经在 3 台不同的计算机上尝试过,甚至让我的一个 friend 在他的 Ubuntu PC 上
我正在考虑设置一个文本到语音的解释器,以使我们的 CAPTCHA 挑战符合 ADA 标准。我们是一家 ColdFusion 商店,Ray Camden 已经在去年完成了概念验证。我一直在这里使用他的博
在带有 FreeTTS 的 Java 程序中使用 MBROLA 语音... 我正在用 Java 开发一个简单的文本到语音程序。我决定使用 FreeTTS,但声音并不是我所想的那样,而且我一直在寻找使用
我正在使用 freeTTS用于将文本转换为语音的库。我可以使用这个库编写我的代码,我可以使用以下代码播放特定文本的语音: Voice voice = VoiceManager.getInstance(
当我运行FreeTTS示例时,出现此错误: LINE UNAVAILABLE: Format is pcm_signed 16000.0 Hz 16 bits 1 channel big endian
我是一名优秀的程序员,十分优秀!