java - java中使用freetts进行文本转语音

标签 java freetts

我正在使用 freetts jar 文件进行文本转语音。 但我需要更多像印度英语这样的声音。

我的代码是:

  import com.sun.speech.freetts.Voice;
  import com.sun.speech.freetts.VoiceManager;

 class s
 {

     VoiceManager freettsVM;
     Voice freettsVoice;
     private Voice voice;
     public s(String voiceName) 
     {
          VoiceManager voiceManager = VoiceManager.getInstance();
           voice = voiceManager.getVoice(voiceName);
      }
      public void speak(String msg) {
          freettsVoice.allocate();
          freettsVoice.speak(msg);
          freettsVoice.deallocate();
      }
 }
 public class Main {
    public static void main(String[] args) {
    String speekstring = txtmassage.getText();
            s t = new s("kevin16");
            t.speak(speekstring);}
 }

工作正常,但我需要更多声音。

现在我将代码更改为 enter image description here

然后出现错误

 Could not validate any MBROLA voices at

  C:/Users/anand/Documents/NetBeansProjects/mbrola

  Make sure you FULLY specify the path to
  the MBROLA directory using the mbrola.base
  system property.

  Exception in thread "main" java.lang.NullPointerException
          at newpro.TestTTS.<init>(TestTTS.java:20)
         at newpro.TestTTS.main(TestTTS.java:29)
  Java Result: 1
  BUILD SUCCESSFUL (total time: 0 seconds)

最佳答案

您可以使用MBROLA - 项目。它是免费的并且提供 多种语言。

您需要下载项目包本身和声音。

有关如何安装和使用 MBROLA 的分步指南,您可以访问此处:

https://stackoverflow.com/a/26236563/1368690

或者转到项目页面本身:

http://tcts.fpms.ac.be/synthesis/mbrola.html

当您向下滚动一点时,您可以测试并查看很多声音,看看它们是否对您有用。

关于java - java中使用freetts进行文本转语音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34724104/

相关文章:

Java 和 Windows - 错误 : illegal escape character

java - 如何通过生成线程来命中 java.lang.OutOfMemoryError?

java - FreeTTS,Java,Linux: “LINE UNAVAILABLE: Format is …”的解决方法

java - 我可以使用 freetts 检测来自音频输入的特定声音吗?

java - 如何修复错误 "cannot be cast to com.sun.speech.freetts.VoiceDirectory"?

java - 为什么 Intellij IDEA 突然不再识别测试文件夹中的测试了?

java - 在递归通用数据结构中对对象进行排序

java - 如果有更好的方法在java中编写这个if语句

Java FreeTTS 缺少语音