我想要做的事:为什么它在开始收听之前不睡3秒钟?
- 执行
TextToSpeech
- SpeechRecognizer开始监听作为用户重复 TextToSpeech'd词/短语
但我的问题是,例如,如果我通过TextToSpeech说“example”,那么当SpeechRecognizer开始收听时,它也会从之前的“示例”中获取并添加到用户所说的“示例”中。最后,我结束了“示例”,这是我不想要的。
代码:
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// TODO Auto-generated method stub
item = (String) parent.getItemAtPosition(position);
tts.speak(item, TextToSpeech.QUEUE_FLUSH, null);
Thread thread = new Thread() {
public void run() {
try {
sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
thread.start();
sr.startListening(srIntent);
}
,因为你的睡眠是把外面的睡眠与另一个线程 – njzk2
线程对象 –
@ njzk2是的正确 – Sameer