Android 语音超时 - 语音识别
Android speech time out - speech recognition
我正在构建一个通过语音识别收集用户数据的应用程序。我的问题是,在调用语音超时错误之前只需要大约 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;
}
}
});
这些可选参数有助于延长时间,如果您需要增加时间(服务通过此参数遵守的时间有限制),那么您将不得不像在 Whosebug 中那样覆盖 recognitionlistener。com/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);
我正在构建一个通过语音识别收集用户数据的应用程序。我的问题是,在调用语音超时错误之前只需要大约 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;
}
}
});
这些可选参数有助于延长时间,如果您需要增加时间(服务通过此参数遵守的时间有限制),那么您将不得不像在 Whosebug 中那样覆盖 recognitionlistener。com/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);