当我们使用Java语音API时如何定义mbrola.base属性?
import javax.speech.EngineList;
import javax.speech.EngineCreate;
import javax.speech.synthesis.SynthesizerModeDesc;
import javax.speech.synthesis.Synthesizer;
import com.sun.speech.freetts.jsapi.FreeTTSEngineCentral;
import java.util.Locale;
public class HelloWorld {
public static void main(String args[]) {
try {
// create SynthesizerModeDesc that will match the FreeTTS Synthesizer
SynthesizerModeDesc modeDesc = new SynthesizerModeDesc(
null,
"general", /* use "time" or "general" */
Locale.US,
Boolean.FALSE,
null);
if(modeDesc == null)
System.out.println("Error creating mode descriptor");
FreeTTSEngineCentral central = new FreeTTSEngineCentral();
Synthesizer synthesizer = null;
EngineList list = central.createEngineList(modeDesc);
if (list.size() > 0) {
EngineCreate creator = (EngineCreate) list.get(0);
synthesizer = (Synthesizer) creator.createEngine();
}
if (synthesizer == null) {
System.err.println("Cannot create synthesizer");
System.exit(1);
}
//get ready to speak
synthesizer.allocate();
synthesizer.resume();
// say hello world
synthesizer.speakPlainText("Hello, world!", null);
// wait until speaking is done and clean up
synthesizer.waitEngineState(Synthesizer.QUEUE_EMPTY);
synthesizer.deallocate();
} catch (Exception e) {
e.printStackTrace();
}
}
}
它向我展示了诸如“系统属性“mbrola.base”未定义。不会使用 MBROLA 声音”之类的内容。那我该怎么办呢? 我听不到任何东西。
import javax.speech.EngineList;
import javax.speech.EngineCreate;
import javax.speech.synthesis.SynthesizerModeDesc;
import javax.speech.synthesis.Synthesizer;
import com.sun.speech.freetts.jsapi.FreeTTSEngineCentral;
import java.util.Locale;
public class HelloWorld {
public static void main(String args[]) {
try {
// create SynthesizerModeDesc that will match the FreeTTS Synthesizer
SynthesizerModeDesc modeDesc = new SynthesizerModeDesc(
null,
"general", /* use "time" or "general" */
Locale.US,
Boolean.FALSE,
null);
if(modeDesc == null)
System.out.println("Error creating mode descriptor");
FreeTTSEngineCentral central = new FreeTTSEngineCentral();
Synthesizer synthesizer = null;
EngineList list = central.createEngineList(modeDesc);
if (list.size() > 0) {
EngineCreate creator = (EngineCreate) list.get(0);
synthesizer = (Synthesizer) creator.createEngine();
}
if (synthesizer == null) {
System.err.println("Cannot create synthesizer");
System.exit(1);
}
//get ready to speak
synthesizer.allocate();
synthesizer.resume();
// say hello world
synthesizer.speakPlainText("Hello, world!", null);
// wait until speaking is done and clean up
synthesizer.waitEngineState(Synthesizer.QUEUE_EMPTY);
synthesizer.deallocate();
} catch (Exception e) {
e.printStackTrace();
}
}
}
It's showing me the thing like "System property "mbrola.base" is undefined. Will not use MBROLA voices." So what should I do?
I am not able to Listen any thing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 voice.properties 文件复制到“java.home”或“user.home”
Copy speech.properties file into "java.home" or "user.home"