FreeTTS无法找到任何声音

编程入门 行业动态 更新时间:2024-10-24 12:32:54
本文介绍了FreeTTS无法找到任何声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用FreeTTS,这是代码:

I am trying to use FreeTTS, here is the code:

import com.sun.speech.freetts.Voice; import com.sun.speech.freetts.VoiceManager; public class FreeTTSVoice { public static final String VOICE_ALAN = "alan"; public static final String VOICE_KEVIN = "kevin"; public static final String VOICE_KEVIN16 = "kevin16"; private Voice voice; public FreeTTSVoice(String voiceName) { VoiceManager voiceManager = VoiceManager.getInstance(); voice = voiceManager.getVoice(voiceName); if (voice == null) { System.err.println( "Cannot find a voice named " + voiceName + ". Please specify a different voice."); System.exit(1); } } public void speak(String msg) { voice.speak(msg); } public void open() { voice.allocate(); } public void close() { voice.deallocate(); } public static void main(String[] args) { System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory"); FreeTTSVoice me = new FreeTTSVoice(FreeTTSVoice.VOICE_KEVIN); me.open(); me.speak("Hello java is smart. isn't is?"); me.close(); }

}

它可以正常编译,但是会引发以下运行时错误:

It compiles fine, but throws the following runtime-error:

pkswatch@neurals:~/dev/java/speech/viame-speech$ javac FreeTTSVoice.java pkswatch@neurals:~/dev/java/speech/viame-speech$ java FreeTTSVoice Exception in thread "main" java.lang.Error: Unable to load voice directory.java.lang.ClassNotFoundException: com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory at com.sun.speech.freetts.VoiceManager.getVoiceDirectories(VoiceManager.java:198) at com.sun.speech.freetts.VoiceManager.getVoices(VoiceManager.java:110) at com.sun.speech.freetts.VoiceManager.getVoice(VoiceManager.java:502) at FreeTTSVoice.<init>(FreeTTSVoice.java:15) at FreeTTSVoice.main(FreeTTSVoice.java:39)

我正在使用: Java版本"1.6.0_24"

I am using: java version "1.6.0_24"

OpenJDK运行时环境(IcedTea6 1.11.3)(6b24-1.11.3-1ubuntu0.12.04.1)

OpenJDK Runtime Environment (IcedTea6 1.11.3) (6b24-1.11.3-1ubuntu0.12.04.1)

OpenJDK Server VM(内部版本20.0-b12,混合模式)

OpenJDK Server VM (build 20.0-b12, mixed mode)

FreeTTS版本1.2.2

FreeTTS version 1.2.2

为什么会出现该错误?请帮助

Why is it giving that error? Please help

推荐答案

可能是某些jar无法正确链接. 我使用Netbeans构建项目后就开始工作!

Probably some jars were not linked correctly.. Started working as soon as i built the project using netbeans!

谢谢大家(@netbeans)..你救了我的日子! :)

Thanks guys (@netbeans).. u saved my day! :)

对于那些可能遇到相同问题的人,请使用netbeans避免麻烦的库.

For those who might be having the same problem, use netbeans to avoid hassle of libraries.

  • 从"freetts-1.2.2-src.zip"中的"lib"文件夹添加lib/freetts.jar (可从 sf 下载)
  • 将jdk文件夹(如果尚未列出)添加到项目库中
  • 您完成了!现在运行代码.
  • add lib/freetts.jar from "lib" folder in "freetts-1.2.2-src.zip" (downloadable from sf)
  • add jdk folder (if not already listed) to project libraries
  • You are done! now run the code.
  • 更多推荐

    FreeTTS无法找到任何声音

    本文发布于:2023-11-11 23:40:02,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1579864.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:声音   FreeTTS

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!