I can provide the code if required. As I mentioned, I don't see this issue on android devices that don't run 5.0. It happens only for Android 5.0 devices. Seems like app gets stuck at "start decoding", but audio buffer doesn't get processed until headset is plugged out. Any pointers to debug this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Any suggestions for properly releasing AudioRecord? Wouldn't that have to be done in your code instead? Any plans to update pocketsphinx-android to correctly handle this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have successfully used pocketsphinx library in my app. Everything works well except the following:
On devices running Android 5.0:
1. Launch the app.
2. Plug in headphones with mic.
3. call startlistening("keyword")
4. App freezes.
When headset is plugged out, app resumes.
Following are the logs when headset is plugged in:
05-19 14:32:47.900 32539-32539/com.handsfreelearning.mobile I/SpeechRecognizer﹕ Start recognition "trigger"
05-19 14:32:47.905 32539-1351/com.handsfreelearning.mobile V/AudioRecord﹕ start, sync event 0 trigger session 0
05-19 14:32:47.905 32539-1351/com.handsfreelearning.mobile W/AudioRecord﹕ dead IAudioRecord, creating a new one from start()
05-19 14:32:47.909 32539-32645/com.handsfreelearning.mobile V/AudioSystem﹕ ioConfigChanged() event 3, ioHandle 567
05-19 14:32:47.922 32539-1351/com.handsfreelearning.mobile D/SpeechRecognizer﹕ Starting decoding
Following are the logs when headset is plugged out:
05-19 14:32:59.836 32539-1351/com.handsfreelearning.mobile W/AudioRecord﹕ dead IAudioRecord, creating a new one from obtainBuffer()
05-19 14:32:59.840 32539-32556/com.handsfreelearning.mobile V/AudioSystem﹕ ioConfigChanged() event 4, ioHandle 567
05-19 14:32:59.853 32539-32645/com.handsfreelearning.mobile V/AudioSystem﹕ ioConfigChanged() event 3, ioHandle 568
05-19 14:33:00.369 32539-1351/com.handsfreelearning.mobile V/AudioRecord﹕ stop()
05-19 14:33:00.369 32539-1351/com.handsfreelearning.mobile D/AudioRecord﹕ AudioRecord->stop()
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ INFO: cmn_prior.c(131): cmn_prior_update: from <
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ 59.26
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ -0.16
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ 2.14
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ 10.13
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ -0.70
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ 3.14
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ 3.07
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ 4.36
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ 2.41
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ 6.32
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ -2.09
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ 2.80
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ 5.28
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ >
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ INFO: cmn_prior.c(149): cmn_prior_update: to <
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ 58.55
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ 0.17
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ 2.19
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ 9.53
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ -0.62
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ 3.02
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ 3.08
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ 4.15
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ 2.38
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ 6.08
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ -1.93
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ 2.74
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ 5.24
05-19 14:33:00.484 32539-1351/com.handsfreelearning.mobile I/cmusphinx﹕ >
05-19 14:33:00.486 32539-32539/com.handsfreelearning.mobile I/SpeechRecognizer﹕ Stop recognition
I can provide the code if required. As I mentioned, I don't see this issue on android devices that don't run 5.0. It happens only for Android 5.0 devices. Seems like app gets stuck at "start decoding", but audio buffer doesn't get processed until headset is plugged out. Any pointers to debug this?
Looks like a bug in Android
https://code.google.com/p/android/issues/detail?id=81241
It might be related to the fact we do not properly release audiorecord in our source:
http://stackoverflow.com/questions/27795851/audiorecord-read-method-blocks-indefinitely-on-android-4-3
A google search on error might give you some more information.
Thanks Nickolay. Is there a way to fix this?
Sure, you need to properly release audiorecord.
Any suggestions for properly releasing AudioRecord? Wouldn't that have to be done in your code instead? Any plans to update pocketsphinx-android to correctly handle this?