疑难解答“系统属性 mbrola.base 未定义。不会使用MBROLA声音”使用 FreeTTS 将文本转换为语音时

发布于 2024-09-28 05:51:25 字数 1047 浏览 3 评论 0原文

 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");
   }
  } 

上面的代码会导致以下错误:

System property "mbrola.base" is undefined.  Will not use MBROLA voices
No Voice Available
java.lang.NullPointerException
        at Demofreetts.doSpeak(Demofreetts.java:24)
        at Demofreetts.main(Demofreetts.java:39)
 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");
   }
  } 

The above code causes the following error:

System property "mbrola.base" is undefined.  Will not use MBROLA voices
No Voice Available
java.lang.NullPointerException
        at Demofreetts.doSpeak(Demofreetts.java:24)
        at Demofreetts.main(Demofreetts.java:39)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

羅雙樹 2024-10-05 05:51:25

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

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

You can convert the text to speech in Java using freetts1.2 API. It is quite simple to use. This link could be useful for you. It has an example program

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

梦里的微风 2024-10-05 05:51:25

只需添加 System.setProperty

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

just add System.setProperty

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

方觉久 2024-10-05 05:51:25

这是解决方案

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

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

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

,它对我有用,请尝试一下。

Here is the solution

Change the string voice parameter to one of the following.

1.kevin16 (all letters should be written in small case)
2.alan (this is also your next option alternate to kevin16 voice.
but the message
System property "mbrola.base" is undefined. Will not use MBROLA voices. Still exist but you can get the voice that you need.fortunately you can solve this problem by setting the property of mbrola voice. Using

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

Anyways it works for me please give it a try.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文