1

I have been using Pocketsphinx Android demo and get the error: "Failed to init recognizer java.io.IOException: Failed to initialize recorder. Microphone might already be in use."

What does the error mean and what can I do to fix it ?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Erz
  • 21
  • 5
  • Possible duplicate of [Unable to access microphone when another app is using it in Android](http://stackoverflow.com/questions/24170124/unable-to-access-microphone-when-another-app-is-using-it-in-android) – Nikolay Shmyrev Sep 27 '16 at 07:36
  • This means that microphone is already used in another application, you can't do much about it. – Nikolay Shmyrev Sep 27 '16 at 07:37
  • @NikolayShmyrev I have closed all other apps using the microphone so it cannot come from another app. – Erz Sep 27 '16 at 08:36
  • @NikolayShmyrev My app has multiple activities using the microphone, it is when my app switches from the first activity to the second where the problem arises. – Erz Sep 27 '16 at 08:37
  • Ok, so you tried to access microphone multiple times yourself, you shouldn't do that. – Nikolay Shmyrev Sep 27 '16 at 11:44
  • @NikolayShmyrev I need to access the microphone throughout each activity in the app. Would there be a way to use onPause() / onResume to fix this ? – Erz Sep 27 '16 at 17:38
  • recognizer.shutdown() releases the recorder. You can invoke it in onPause(). – Nikolay Shmyrev Sep 27 '16 at 21:35

1 Answers1

1

If you upgrade your Android OS to 6 or it is already 6, you have to ask permission in runtime. Android manifest recorder permission is not enough after Android OS 6. It will give this error if you do not ask permission.

sersem1
  • 466
  • 1
  • 4
  • 10