How to define mbrola.base property while we are using the Java speech API?
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 FreeTT开发者_开发技巧SEngineCentral();
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.
Copy speech.properties file into "java.home" or "user.home"
精彩评论