怎么实现多次朗读,我用了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();
} }
}
}

解决方案 »

  1.   

                    System.exit(0);你这一行是什么意思……
      

  2.   

    LZ,System.exit(0)表示的是程序正常的退出
    所以你的循环只循环了1次。。
    将这条语句删了。。
      

  3.   

    参考资料:
    http://freetts.sourceforge.net/docs/index.php
      

  4.   

    楼主,其实我觉得最好的方式就是……你把整个synthesizer 的生成和销毁的过程放到循环体外面去。