SpeechRecognizer, bind to recognition service failed

7.4k views Asked by At

I used SpeechRecognizer on android to recognize the User's voice. It worked well until uninstall the Google App. (https://play.google.com/store/apps/details?id=com.google.android.googlequicksearchbox&hl=en)

I updated the Google App, but I got errors such as "bind to recognition service failed". How can I make the app run successfully?

What should I do to use SpeechRecognizer normally?

Thanks.

4

There are 4 answers

0
Vikram Ezhil On BEST ANSWER

Every time the Google app is updated some way or the other there is always an issue with the speech recognizer callbacks. Either Google periodically changes their timeout clause or some weird issues like yours pops out of nowhere.

You need to make your code dynamic in such a way that even if there is an error in the speech callback methods, you need to catch that error and try listening again automatically. This has been discussed widely in this post and there are plenty of answers provided for you to check and implement them based on your requirement.

If you don't want this you can always try out DroidSpeech library which takes care of these speech error issues whenever something pops up and provides you with continuous voice recognition.

Just implement the library using Gradle and add the following lines of code.

DroidSpeech droidSpeech = new DroidSpeech(this, null); droidSpeech.setOnDroidSpeechListener(this);

To start listening to the user call the below code,

droidSpeech.startDroidSpeechRecognition();

And you will get the voice result in the listener method,

@Override

public void onDroidSpeechFinalResult(String finalSpeechResult, boolean droidSpeechWillListen) {

}

4
Damercy On

Update manifest

I'm using Algolia's voice input library and it was failing to take voice input on Pixel 2 and android 11 devices. The reason being unable to bind to voice recognition service.

To solve it, In the manifest file, insert this query element just under your ​opening tag:

<queries>
        <package android:name="com.google.android.googlequicksearchbox"/>
</queries>
0
Dan Alboteanu On

You need to add this in the manifest like so:

  <uses-permission android:name="android.permission.RECORD_AUDIO" />
**<queries>
    <intent>
        <action android:name="android.speech.RecognitionService" />
    </intent>
</queries>**
2
Khaled Abdrabo On

I know I am answering this a bit late but I have struggled with this error for a while now. It turns out you need to activate Google's Quick Search Box. So the solution I used is: I check if the SpeechRecognizer is available (using isRecognitionAvailable(context)). If the SpeechRecognizer is not available, you can activate it like this :

if(!SpeechRecognizer.isRecognitionAvailable(mainActivity)){
    String appPackageName = "com.google.android.googlequicksearchbox";
    try {
        mainActivity.startActivity(new Intent(Intent.ACTION_VIEW,
            Uri.parse("market://details?id=" + appPackageName)));
    } catch (android.content.ActivityNotFoundException anfe) {
        mainActivity.startActivity(new Intent(Intent.ACTION_VIEW,
            Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
    }
}