Menu

pocketshpinx on android while recording audio

Help
Asaf
2016-11-28
2016-11-30
  • Asaf

    Asaf - 2016-11-28

    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:

    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!

     
    • Nickolay V. Shmyrev

      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.

       
  • Asaf

    Asaf - 2016-11-30

    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

     
    • Nickolay V. Shmyrev

      Yes, sure, you do not need speechrecognizer then, you can simply use Decoder object.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.