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语音。”所以我该怎么做? 我无法倾听任何事情。
答案 0 :(得分:1)
将speech.properties文件复制到“java.home”或“user.home”
答案 1 :(得分:0)