我在android.speech.SpeechRecognizer
中使用DICTATION_MODE
来识别很长一段时间内的命令。在此模式下,对回调方法onPartialResults
的调用比正常模式下的延迟要多得多。有谁知道为什么会发生这种情况以及如何避免这种延迟?
这是我用于SpeechRecognizer
的配置:
Intent recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
recognizerIntent.putExtra("calling_package", mainActivity.getApplicationContext().getPackageName());
recognizerIntent.putExtra("android.speech.extra.DICTATION_MODE", true);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 100);
答案 0 :(得分:1)
问题可能是由于互联网速度所致。
尝试将EXTRA_PREFER_OFFLINE
设置为true,并检查延迟是否会减少
https://developer.android.com/reference/android/speech/RecognizerIntent.html#EXTRA_PREFER_OFFLINE
答案 1 :(得分:-1)
响应时间取决于许多因素,例如:
并且通常它更长,因为这种模式意味着猜测上下文并试图用每个新单词弄清楚这些变化的含义。