David Brown
David Brown

Reputation: 4823

Recording Voice on Android Phone

I want to record the Voice on my android mobile and I have no clue how to do that particularly. I have searched a lot but couldn't found anything useful.

Can anyone have a solution to this particularly.

Thanks, david

Upvotes: 1

Views: 1463

Answers (2)

Android Eve
Android Eve

Reputation: 14974

Check out this Android Audio Recording Tutorial.

Upvotes: 2

Jason Rogers
Jason Rogers

Reputation: 19344

Depends which voice you want ^^

if you want to do a memo/dictaphone application then read on

if your trying to record a conversation, then its not possible at the time being at least (trust me I spend 1 month searching this with my colleagues).

so if you want to record your voice try this:

public class StreamerAudio implements Runnable {

    private static FileOutputStream fOut;
    public static boolean isRecording = false;
    private int buffersize;
    private static AudioRecord arec;

    private int encoding = AudioFormat.ENCODING_PCM_16BIT; 
    private int audioChannel = AudioFormat.CHANNEL_CONFIGURATION_DEFAULT;

    private int audioSource = MediaRecorder.AudioSource.VOICE_DOWNLINK;


    private static MicProject parent = null;

    public StreamerAudio(MicProject parent_){
        this.parent = parent_;
    }

    @Override
    public void run() {
        //openFile();

        buffersize = (int) AudioRecord.getMinBufferSize(11025,audioChannel,AudioFormat.ENCODING_PCM_16BIT);
        arec = new AudioRecord(audioSource,
                11025,
                audioChannel,
                encoding,
                buffersize);
        byte[] buffer = new byte[buffersize];
        byte[] buffer2 = new byte[buffersize];
        byte[] bufferSwap = buffer;

        arec.startRecording();

        isRecording = true;

        while(isRecording) {
            arec.read(buffer, 0, buffersize);
                printBuffer(buffer);
        }  
    }

    public void printBuffer(byte[] buffer) {
        try {
            parent.setBufferToDisplay(buffer);
        } catch (Exception e) {

}

Upvotes: 0

Related Questions