疑难解答“系统属性 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");
}
}
上面的代码会导致以下错误:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 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
只需添加 System.setProperty
just add System.setProperty
这是解决方案
将字符串语音参数更改为以下之一。
1.kevin16(所有字母均应小写)
2.alan(这也是您替代 kevin16 语音的下一个选择。
但消息
系统属性“mbrola.base”未定义。不会使用 MBROLA 声音。仍然存在,但你可以获得你需要的声音。幸运的是,你可以通过设置 mbrola 声音的属性来解决这个问题。不管怎样
,它对我有用,请尝试一下。
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
Anyways it works for me please give it a try.