我的代码:
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;
}
}
});
答案 0 :(得分:0)
这些可选参数有助于延长时间,如果您需要增加时间(服务通过该参数遵守的时间有限制),则您将必须像stackoverflow.com/a/49810988/806328中那样覆盖重写器识别侦听器
recognizerIntent.PutExtra(RecognizerIntent.ActionRecognizeSpeech, RecognizerIntent.ExtraPreferOffline);
recognizerIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 1000);
recognizerIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1000);
recognizerIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 1500);