3
我使用SppechRecognizer作为语音识别器应用程序。它的工作正常。我的要求是我想在1秒或2秒后停止收听。如何实现这一目标?SpeechRecognizer - 时间限制
我使用SppechRecognizer作为语音识别器应用程序。它的工作正常。我的要求是我想在1秒或2秒后停止收听。如何实现这一目标?SpeechRecognizer - 时间限制
1或2秒似乎不是很多时间,但如果你想设置一个时间限制,你可能需要线程。 Android有一些默认的额外功能,用来设置语音输入的最小长度和用户停止说话后的最大音量,但没有设置语音输入的最大时间长度。
你最好的选择将是线程某种定时器,像一个CountDownTimer:
yourSpeechListener.startListening(yourRecognizerIntent);
new CountDownTimer(2000, 1000) {
public void onTick(long millisUntilFinished) {
//do nothing, just let it tick
}
public void onFinish() {
yourSpeechListener.stopListening();
}
}.start();
我也会鼓励你看看可用于RecognizerIntent群众演员,看看是否有什么更适合您的需求。
谢谢奥特拉。这是我需要的确切场景。我希望你也可以帮助我解决这个问题http://stackoverflow.com/questions/11105937/how-to-get-speechrecognizer-listner-response-in-js-function/ – littledev