I'm using VOCE library(https://sourceforge.net/projects/voce/) for speech synthesis in Java with netbeans for an application and below is the code.
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);
}
}
However when I run this code the output is
[Voce] Initializing synthesizer
[Voce] Initialization complete
[Voce] Shutdown complete
BUILD SUCCESSFUL (total time: 0 seconds)
but no voice output. However it is giving output if the string is read from console. How to fix this as I want this to work for the string provided in the code?
You call
voce.SpeechInterface.synthesize(s);
That starting the speech
voce.SpeechInterface.stopSynthesizing();
From documentation: "Tells the speech synthesizer to stop synthesizing. This cancels all pending messages. "
Then the speech is immediately stopped.
You must wait the end of the speech without forcing to stop it. This must done in a loop else the application end before the speech.