androidaudiogoogle-glassaudio-recordingaero-glass

How to record audio with Google Glass?


I want to record audio with Google Glass and be able to save into an audio file. I've tried with MediaStore.Audio.Media.RECORD_SOUND_ACTION intent but it doesn't work. I've also tried with RecognizerIntent.ACTION_RECOGNIZE_SPEECH intent but it neither works.

Has anybody tried to do this?

Thanks!


Solution

  • Here are the instructions from the Android Media Recording site(http://developer.android.com/guide/topics/media/audio-capture.html):

    1. Create a new instance of android.media.MediaRecorder.
    2. Set the audio source using MediaRecorder.setAudioSource(). You will probably want to use MediaRecorder.AudioSource.MIC.
    3. Set output file format using MediaRecorder.setOutputFormat().
    4. Set output file name using MediaRecorder.setOutputFile().
    5. Set the audio encoder using MediaRecorder.setAudioEncoder().
    6. Call MediaRecorder.prepare() on the MediaRecorder instance.
    7. To start audio capture, call MediaRecorder.start().
    8. To stop audio capture, call MediaRecorder.stop().
    9. When you are done with the MediaRecorder instance, call MediaRecorder.release() on it. Calling MediaRecorder.release() is always recommended to free the resource immediately.

    The reason for your error may be that you didn't ask for permission to access the microphone. Here is the permission I have in my AndroidManifest.xml file in my Glass project which successfully records audio:

    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    

    Simply add that to AndroidManifest.xml and you should be good if you follow the instructions above.

    Hope that helps :) Good luck!