怎么实现多次朗读,我用了for ( int i = 0; i < 2; i++ )循环,可只朗读了一次。public class HelloWorld
{ public static void main(String[] args)
{ for ( int i = 0; i < 2; i++ )
{
try
{ SynthesizerModeDesc desc = new SynthesizerModeDesc(null, // engine
// name
"general", // mode name
Locale.US, // locale
null, // running
null); // voice
Synthesizer synthesizer = Central.createSynthesizer(desc); synthesizer.allocate();
synthesizer.resume(); synthesizer.speakPlainText("why it is so hard!", null);
synthesizer.waitEngineState(Synthesizer.QUEUE_EMPTY); synthesizer.deallocate();
System.exit(0); }
catch (Exception e)
{
e.printStackTrace();
} }
}
}
{ public static void main(String[] args)
{ for ( int i = 0; i < 2; i++ )
{
try
{ SynthesizerModeDesc desc = new SynthesizerModeDesc(null, // engine
// name
"general", // mode name
Locale.US, // locale
null, // running
null); // voice
Synthesizer synthesizer = Central.createSynthesizer(desc); synthesizer.allocate();
synthesizer.resume(); synthesizer.speakPlainText("why it is so hard!", null);
synthesizer.waitEngineState(Synthesizer.QUEUE_EMPTY); synthesizer.deallocate();
System.exit(0); }
catch (Exception e)
{
e.printStackTrace();
} }
}
}
所以你的循环只循环了1次。。
将这条语句删了。。
http://freetts.sourceforge.net/docs/index.php