i want to use pocketsphinx in my app while recording audio in the background (unrelated to the speech recognition - as part of a video recording). while trying to do so i constantly get the exception: ErrorFailed to start recording. Microphone might be already in use.
I understand that in android two different activities cannot share the mic, but since i'm using a different audio source i was hoping there is a way to overcome this problem.
From what i saw pocketsphinx is using a new AudioRecord with an audioSource==VoiceRecognition:
this.recorder = new AudioRecord(6, this.sampleRate, 16, 2, this.bufferSize * 2);
while the first function param is AudioSource, and 6 is VOICE_RECOGNITION.
since i'm using a different audio source for the audio recording, i hope there is a way to avoid this exception.
Any other solutions/workarounds would also be helpful.
Thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The solution would be to modify recognizerThread inside SpeechRecognizer in pocketsphinx and process the buffer the way you need instead of simply pushing it to recognizer.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
if we would go the other way around, meaning passing the audio recording output to SpeechRecognizer, what would be the best way to do it?
it seems that SpeechRecognizer expects a short array, let's say with size N. if we would create a new buffer (of size N) and wait untill it's filled and then pass it to SpeechRecognizer, and repeat this process while passing a new array each time, should that do the trick?
thanks again
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
i want to use pocketsphinx in my app while recording audio in the background (unrelated to the speech recognition - as part of a video recording). while trying to do so i constantly get the exception:
ErrorFailed to start recording. Microphone might be already in use.
I understand that in android two different activities cannot share the mic, but since i'm using a different audio source i was hoping there is a way to overcome this problem.
From what i saw pocketsphinx is using a new AudioRecord with an audioSource==VoiceRecognition:
while the first function param is AudioSource, and 6 is VOICE_RECOGNITION.
since i'm using a different audio source for the audio recording, i hope there is a way to avoid this exception.
Any other solutions/workarounds would also be helpful.
Thanks!
The solution would be to modify recognizerThread inside SpeechRecognizer in pocketsphinx and process the buffer the way you need instead of simply pushing it to recognizer.
Thank you for the quick response!
if we would go the other way around, meaning passing the audio recording output to SpeechRecognizer, what would be the best way to do it?
it seems that SpeechRecognizer expects a short array, let's say with size N. if we would create a new buffer (of size N) and wait untill it's filled and then pass it to SpeechRecognizer, and repeat this process while passing a new array each time, should that do the trick?
thanks again
Yes, sure, you do not need speechrecognizer then, you can simply use Decoder object.