3

I stumbled with this random issue... Here is my code

mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(mContext);
        initializeRecognitionListener();
        mSpeechRecognizer.setRecognitionListener(mRecognitionListener);

    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
                    RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getClass().getPackage().getName());
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");
            intent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS, Long.valueOf(3000L));
    intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 5);
    mSpeechRecognizer.startListening(intent);

Method initializeRecognitionListener():

private void initializeRecognitionListener() {
    mRecognitionListener = new RecognitionListener() {

    @Override        
    public void onReadyForSpeech(Bundle params) {
        Log.d("onReadyForSpeech()", "onReadyForSpeech!");
        isRecognizing = true;
    }

    @Override
    public void onBeginningOfSpeech() {
        Log.d("onBeginningOfSpeech()", "onBeginningOfSpeech!");

    }

    @Override
    public void onEndOfSpeech() {
        Log.e("onEndOfSpeech()", "onEndOfSpeech! stop SCO");
    }
     ... 
}

Main issue that is "onReadyForSpeech()" and "onBeginningOfSpeech()" methods sometimes doesn't called after mSpeechRecognizer.startListening(intent). Also "onEndOfSpeech()" also can be not called.

I'm using Nexus 4 with Android 4.2.2

pbelov
  • 445
  • 6
  • 20
  • Did you ever solve this? I have the same exact issue! – Mike6679 Sep 06 '13 at 03:57
  • No, I didn't. Currently it works fine on my Nexus, but works very bad on HTC One S. Moreover I often can see an error "Recognizer busy". As I can understand, it is normal behavior for free version of Google Voice Recognizer. – pbelov Sep 14 '13 at 16:22
  • yes that's what I have the HTC One.there is a paid version of the Google Voice recognizer? – Mike6679 Sep 15 '13 at 01:22
  • As I heard, yes, but I didn't find any info about paid version – pbelov Sep 16 '13 at 10:56

2 Answers2

2

I posted a very similar answer on another post:

This is a Google Voice Search/Jelly Bean bug that has been outstanding on the AOSP bug tracker for nearly a year.

I posted on the Google Product Forum about it here too, but no response. If you are reading this and would like these issues to be resolved, please do star the AOSP issue and comment on the Product Forum post to get it noticed!

To work around this issue, you'll need an implementation such as the one demonstrated here.

In my testing today, it does appear that the latest version of Google Search has fixed this problem internally though - So update Google Search on the Play Store and this problem may disappear - If that's not the case for you, please do comment below, as it may be fixed in only certain versions of the Google Search apk, in which case it would be helpful to know where these variations occur to handle them gracefully in our code!

Community
  • 1
  • 1
brandall
  • 6,094
  • 4
  • 49
  • 103
  • I have a `Nexus S` running Android `4.1.2`, latest & greatest Google `Voice Search` and I am experiencing the same problems. Is "Google Search" same as Google's "Voice Search"? If not, where do I find "Google Search" on Google Play? Thanks. – ih8ie8 Jan 21 '15 at 03:19
1

Seems to be I've fixed my problem. Main idea to fix is keep single instance of SpeechRecognizer object instead of recreating it each time. After these changes I didn't get any "Recognizer busy" error. But my HTC One S still freezes when I use my app. I could not understand why...

pbelov
  • 445
  • 6
  • 20