【问题标题】:Troubleshooting "System property mbrola.base is undefined. Will not use MBROLA voices" when converting text to speech using FreeTTS使用 FreeTTS 将文本转换为语音时,“系统属性 mbrola.base 未定义。不会使用 MBROLA 语音”疑难解答
【发布时间】:2010-10-20 08:15:58
【问题描述】:
 import com.sun.speech.freetts.*;
 import java.util.*; 

 public class Demofreetts
  {
   private String speaktext;
   public void doSpeak(String speak, String voice)
    {
     speaktext = speak;
     try
      {
       VoiceManager voiceManager = VoiceManager.getInstance();
       Voice voices = voiceManager.getVoice(voice);
       Voice sp = null;

       if(voices != null)
         sp = voices;

       else
         System.out.println("No Voice Available");



        sp.allocate();
        sp.speak(speaktext);
        sp.deallocate();



      }
     catch(Exception e)
      {
       e.printStackTrace();
      }
    }
   public static void main(String[]args)
   {
    Demofreetts obj = new Demofreetts();
    obj.doSpeak(args[0],"Kelvin16");
   }
  } 

以上代码导致如下错误:

系统属性“mbrola.base”未定义。不会使用 MBROLA 声音 没有可用的语音 java.lang.NullPointerException 在 Demofreetts.doSpeak(Demofreetts.java:24) 在 Demofreetts.main(Demofreetts.java:39)

【问题讨论】:

    标签: text-to-speech freetts


    【解决方案1】:

    您可以使用 freetts1.2 API 将文本转换为 Java 中的语音。使用起来非常简单。此链接可能对您有用。它有一个示例程序

    http://learnsharelive.blogspot.com/2011/01/convert-text-to-speech-java-freetts12.html

    【讨论】:

      【解决方案2】:

      只需添加 System.setProperty

        System.setProperty("mbrola.base", "C:\\Users\\iup\\workspace\\newpro\\mbrola");
        VoiceManager voiceManager = VoiceManager.getInstance();

      【讨论】:

        【解决方案3】:

        解决办法

        将字符串语音参数更改为以下之一。

        1.kevin16(所有字母小写) 2.alan(这也是您替代 kevin16 语音的下一个选项。 但消息 系统属性“mbrola.base”未定义。不会使用 MBROLA 声音。仍然存在,但你可以得到你需要的声音。幸运的是你可以通过设置 mbrola voice 的属性来解决这个问题。使用

             System.setProperty (" mbrola.base" ,"here the pathof property");.
        

        无论如何它对我有用,请试一试。

        【讨论】:

          猜你喜欢
          • 2011-04-27
          • 2013-12-17
          • 2023-03-09
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2023-01-09
          • 1970-01-01
          • 2014-12-01
          相关资源
          最近更新 更多