故障排除"系统属性mbrola.base未定义.不会使用MBROLA语音"使用FreeTTS将文本转换为语音时 [英] Troubleshooting "System property mbrola.base is undefined. Will not use MBROLA voices" when converting text to speech using FreeTTS

查看:213
本文介绍了故障排除"系统属性mbrola.base未定义.不会使用MBROLA语音"使用FreeTTS将文本转换为语音时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 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)

推荐答案

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

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

这篇关于故障排除"系统属性mbrola.base未定义.不会使用MBROLA语音"使用FreeTTS将文本转换为语音时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆