我正在构建一个通过语音识别收集用户数据的应用程序。我的问题是,在调用语音超时错误之前,只需大约5秒,就可以阻止语音识别器识别任何其他声音。我的问题是:,如何增加超时错误的时间,或者如何停止错误。
我的代码:
SpeechRecogniser sr = createSpeechRecogniser(this)
recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE,"en");
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 3);
sr.startListening(recogniserIntent);
sr.setOnRecognitionListener(new OnRecognitionListener(){
//implenent all its methods
onError(int code){
switch(code){
case ERROR_SPEECH_TIMEOUT:
//this is where the error is called and stops the speech recogniser
//i want the time for this error to be increased
break;
}
}
});发布于 2019-01-15 11:41:27
这些可选参数有助于延长时间,如果需要超出(服务通过此参数尊重的时间有限制),则必须覆盖stackoverflow.com. you /a/49810988/806328中的识别器侦听器。
recognizerIntent.putExtra(RecognizerIntent.ACTION_RECOGNIZE_SPEECH, RecognizerIntent.EXTRA_PREFER_OFFLINE);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS, 1000);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS, 1000);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS, 1500);https://stackoverflow.com/questions/54196738
复制相似问题