[英]how to call speak method multiple times
I'm trying to call the speak
method of class TextToSpeech
multiple times, but it does not seem to work - it only speaks the last phrase each time. 我想打电话给speak
类的方法, TextToSpeech
多次,但它似乎没有工作-它每次只说最后一句。
String temp="ABCD";
ss(temp);
String temp1="WXYZ";
ss(temp1);
public void ss(String t){
tts.speak(t, TextToSpeech.QUEUE_FLUSH, null);
}
tts
is an object of class TexttoSpeech
method. tts
是TexttoSpeech
方法类的对象。
your question does not explains if multiple time is simultany or every time 5 seconds for example, however you can try: 例如,您的问题无法解释多个时间是同时出现还是每5秒出现一次,但是您可以尝试:
Thread thread = new Thread(new Runnable() { @Override public void run() { ss("string text"); } }); thread.start();
Change: 更改:
tts.speak(t, TextToSpeech.QUEUE_FLUSH, null);
...to... ...至...
tts.speak(t, TextToSpeech.QUEUE_ADD, null);
FLUSH always stops speaking whatever is being spoken and clears the buffer. FLUSH始终停止讲话,并清除缓冲区。 ADD will add the new text to the queue. ADD会将新文本添加到队列中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.