0
我使用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(一個或多個); voce.SpeechInterface.stopSynthesizing();在這些線之間放置一個睡眠(3000)。 – Tokazio
怎麼樣? voce.SpeechInterface.synthesize(一個或多個); – Subhiksh
在voce文檔中,用於stopSynthetizing():「告訴語音合成器停止合成,取消所有待處理的消息。 」 – Tokazio