【问题标题】:text to speech in java using freetts使用freetts在java中的文本到语音
【发布时间】:2016-01-14 00:24:33
【问题描述】:

我正在将 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);}
 }

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

现在我把我的代码改成了

那就有错误了

 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)

【问题讨论】:

    标签: java freetts


    【解决方案1】:

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

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

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

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

    或者转到项目页面本身:

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

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

    【讨论】:

    • @anand:两件事 - 1)“请”会很好。 ;) ... 2) 通过在错误消息上使用谷歌,我发现:stackoverflow.com/questions/13810052/… ...这应该有助于 MBROLA 找到路径并因此对其进行验证。
    猜你喜欢
    • 2013-12-17
    • 1970-01-01
    • 1970-01-01
    • 2017-12-29
    • 2019-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多