Android SpeechRecognizer Audio Recording Error
Asked Answered
W

5

6

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!!

Weimer answered 23/9, 2017 at 4:54 Comment(4)
Once try with giving permission of RECORD_AUDIO and check.Hominoid
Use Log.d("test" , audiorecorder); . and run the app in that device in which it is not working. after using, please post here what is written in logcat debugDew
RECORD_AUDIO is alrady added.Weimer
@Zoffa Would you please let me know which audiorecorder you want me to log?Weimer
A
16

I had the same error when Google App(com.google.android.googlequicksearchbox) does not have recording permission.

In addition, SpeechRecognizer uses service of com.google.android.googlequicksearchbox. Thus, if this app is disabled or uninstalled, SpeechRecognizer may not work.

Artistic answered 28/12, 2017 at 10:58 Comment(1)
This answer worked for me. Go to Settings -> Apps in your mobile and give 'Recording' permission to Google app.Setup
M
8

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).

Mutt answered 1/10, 2018 at 13:10 Comment(0)
D
2
<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.

Dew answered 23/9, 2017 at 6:15 Comment(2)
Both permissions already have been added. Mostly Lenovo devices have an issueWeimer
I got this error while calling with WebRTC, it's seem device does not allow to run both speech and webrtc in same timePitapat
J
0

Assuming you have already added permissions to manifest. You should bring Google Voice dialog to user in order to make him give permission to record audio to Google Voice engine. After that you can invoke SpeechRecognizer.

Juice answered 4/9, 2023 at 11:54 Comment(0)
T
-2

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.

Teutonism answered 29/9, 2017 at 17:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.