Android SpeechRecognizer Audio Recording Error

Viewed 5087

I'm trying to use SpeechRecognizer on Android without Intent Dialog. It works fine on most of devices but some devices return Audio Recording Error (Error Code 3) and There's no detail for this error. Is there any solution or reason for this?

Thank you!!

4 Answers

You should go to system setting, Apps, Google app, then enable its permission of microphone. That's exactly the cause of ERROR_AUDIO(Error Code 3).

<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>

Set this in your manifest. if still not working, then state which device is causing error.

Error Code 6 means Error Speech Timeout, while Audio Recording Error has value 3 (see here: https://developer.android.com/reference/android/speech/SpeechRecognizer.html). Assuming that you have Error Speech Timeout, you can do the following:

public void OnError(SpeechRecognizerError error) {
String errorMessage = error.ToString();
    if (errorMessage.Contains ("SpeechTimeout"))
                {   this.OnDestroy();
                    this.OnCreate();
                }
}

This will allow you to restart your SpeechRecognizer.

On the other hand, if you are having difficulties with Audio Recording Error, I'd be glad to find the solution, since I'm facing the same problem.

Related