无语音输出
No voice output
我正在使用 VOCE 库 (https://sourceforge.net/projects/voce/) 在 Java 中使用 netbeans 进行语音合成,下面是代码。
public class synthesisTest{
public static void main(String[] argv){
voce.SpeechInterface.init("../../../lib", true, false, "", "");
voce.SpeechInterface.synthesize("This is a speech synthesis test.");
voce.SpeechInterface.synthesize("Type a message to hear it spoken "
+ "aloud.");
try
{
String s = "Hey testing";
voce.SpeechInterface.synthesize(s);
voce.SpeechInterface.stopSynthesizing();
}
catch (Exception ioe)
{
System.out.println( "error:" + ioe );
}
voce.SpeechInterface.destroy();
System.exit(0);
}
}
但是当我 运行 这段代码的输出是
[Voce] Initializing synthesizer
[Voce] Initialization complete
[Voce] Shutdown complete
BUILD SUCCESSFUL (total time: 0 seconds)
但没有语音输出。但是,如果从控制台读取字符串,它会给出输出。如何解决这个问题,因为我希望它适用于代码中提供的字符串?
你打电话
voce.SpeechInterface.synthesize(s);
即开始演讲
voce.SpeechInterface.stopSynthesizing();
来自文档:"Tells the speech synthesizer to stop synthesizing. This cancels all pending messages. "
然后话音立马停止
你必须等待演讲结束,不要强行停止。
这必须在循环中完成,否则应用程序会在演讲前结束。
我正在使用 VOCE 库 (https://sourceforge.net/projects/voce/) 在 Java 中使用 netbeans 进行语音合成,下面是代码。
public class synthesisTest{
public static void main(String[] argv){
voce.SpeechInterface.init("../../../lib", true, false, "", "");
voce.SpeechInterface.synthesize("This is a speech synthesis test.");
voce.SpeechInterface.synthesize("Type a message to hear it spoken "
+ "aloud.");
try
{
String s = "Hey testing";
voce.SpeechInterface.synthesize(s);
voce.SpeechInterface.stopSynthesizing();
}
catch (Exception ioe)
{
System.out.println( "error:" + ioe );
}
voce.SpeechInterface.destroy();
System.exit(0);
}
}
但是当我 运行 这段代码的输出是
[Voce] Initializing synthesizer
[Voce] Initialization complete
[Voce] Shutdown complete
BUILD SUCCESSFUL (total time: 0 seconds)
但没有语音输出。但是,如果从控制台读取字符串,它会给出输出。如何解决这个问题,因为我希望它适用于代码中提供的字符串?
你打电话
voce.SpeechInterface.synthesize(s);
即开始演讲
voce.SpeechInterface.stopSynthesizing();
来自文档:"Tells the speech synthesizer to stop synthesizing. This cancels all pending messages. "
然后话音立马停止
你必须等待演讲结束,不要强行停止。 这必须在循环中完成,否则应用程序会在演讲前结束。