使用 freetts 在 java 中进行文字转语音

text to speech in java using 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);}
 }

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

现在我将代码更改为

然后是错误

 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 - 项目。它是免费的,并提供 多种语言。

您需要下载 project-package 本身和声音。

有关如何安装和使用 MBROLA 的 step-by-step 指南,您可以转到此处:

或转到项目页面本身:

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

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