我正在尝试做:
- 执行一个
TextToSpeech
- 当用户重复 TextToSpeech 的单词/短语时,SpeechRecognizer 开始收听
但我的问题是,例如,如果我要通过 TextToSpeech 说“示例”,当 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);
}