58

I'm using android.speech.SpeechRecognizer in DICTATION_MODE to recognize commands during a long period of time. In this mode the call to the callback method onPartialResults delays much more than in normal mode. Does anybody know why this happen and how to avoid this delay?

This is the configuration I use for the 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);
Jintin
  • 1,426
  • 13
  • 22
acimutal
  • 2,155
  • 2
  • 17
  • 22
  • 1
    I would suggest you take a look and play around with those flags from **RecognizerIntent** class and put additional values into your Intent object. `EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS` <-- especially this one `EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS` `EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS` This one may be problematic as it behaviours differently based on the Android version and your device's model. Also, take a look on those: https://code.google.com/p/android/issues/detail?id=76130 I wanted to post it as an answer, but decided that comment would be better. – scana Dec 15 '15 at 18:31
  • Yes, I also tried these options without success. Any other suggestion? – acimutal Dec 19 '15 at 09:33
  • you're at the mercy of the installed speech recognizer. it's probably waiting to collect more context to help produce more accurate dictation. if you're unhappy with it, there's nothing to be done short of using a different speech recognition engine. – j__m Nov 03 '16 at 07:05
  • answer here - stackoverflow.com/a/49810988/806328 – Karan Harsh Wardhan Jan 18 '19 at 11:54

2 Answers2

1

The problem may be because of the internet speed.

Try to set EXTRA_PREFER_OFFLINE to true and check whether the delay will be reduced

https://developer.android.com/reference/android/speech/RecognizerIntent.html#EXTRA_PREFER_OFFLINE

Grountex
  • 11
  • 1
-1

Response time depends on many factors, such as:

  • device characteriscics
  • OS version
  • internet speed

And in common it is longer because this mode implies guessing the context and try to figure out meaning of that changes with each new word.

Aniruddh Parihar
  • 3,072
  • 3
  • 21
  • 39