在DICTATION_MODE中使用android.speech.SpeechRecognizer时出现延迟

aci*_*tal 58 android speech-recognition

我用android.speech.SpeechRecognizerDICTATION_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);
Run Code Online (Sandbox Code Playgroud)

小智 -1

响应时间取决于许多因素,例如:

  • 装置特性
  • 操作系统版本
  • 网速

通常它会更长,因为这种模式意味着猜测上下文并尝试找出每个新单词变化的含义。