Troubleshooting “System property mbrola.base is undefined. Will not use MBROLA voices” when converting text to speech using FreeTTS

落花浮王杯 提交于 2019-12-12 03:55:51

问题


 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)

回答1:


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




回答2:


just add System.setProperty

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



回答3:


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.



来源:https://stackoverflow.com/questions/3975906/troubleshooting-system-property-mbrola-base-is-undefined-will-not-use-mbrola

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!