4

I am attempting to add custom voice commands to a glass app by using AudioRecorder to grab input from the microphone and do speech recognition on that. Everything is working great except for the command to "stop recording", where I need to grab the current microphone input at the same time that a MediaRecorder object is recording the video.

Specifically, I don't get any errors, but doing a

int bufferResult = recorder.read(readBuffer, 0, readBuffer.length);

results in 0 bytes being read, and bufferResult being 0. readBuffer.length is 64000 bytes (4 seconds worth of audio)

I suspect that that there is some sort of lock on the underlying resources that is preventing from AudioRecorder from doing .reads() while MediaRecorder is recording as well. Has anyone run into this issue before? More generally, is there any way to get the audio from the microphone while MediaRecorder is recording, either via AudioRecorder or otherwise?

brettcvz
  • 2,371
  • 1
  • 13
  • 14
  • Is it your app's MediaRecorder instance that is causing the problem, or some other app's? Why do you want to simultaneously record audio in an AudioRecorder and video in a MediaRecorder? Can't MediaRecorder do both? I ask because I may soon want to do something similar, and would like to know if this area is problematic. – swooby Apr 05 '14 at 20:49
  • Given the way glass works, I can be sure that it's not some other app's MediaRecorder instance. As I noted in the question, I want the MediaRecorder to record both audio and video, and "fork" the audio stream so that AudioRecorder can grab it as well. One audio stream is for the video being recorded, the other is to listen for voice commands like "Stop recording" – brettcvz Apr 07 '14 at 20:32
  • I suggest you to use android core (c, c++) API's through jni to record video and from UI side listen for voice recognition – support_ms Feb 17 '16 at 14:27
  • 1
    @brettcvz in my app am using both media recorder(to record audio in mp3 format) and audiorecorder(to show waves) but i cant use both at sametime so did you find solution to use both at same time? – Kriti Jan 08 '18 at 07:00
  • @brettcvz Did you find any solution for this. I too have the same problem. Have you found out any workarounds for this ? – Kautham Krishna Jul 09 '19 at 12:03

0 Answers0