amir ghorbani
amir ghorbani

Reputation: 143

How to improve the android recorded voice quality

I have the following code for recording audio/voice in android:

MediaRecorder recorder=new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setAudioEncodingBitRate(16);
recorder.setAudioSamplingRate(44100);
recorder.setOutputFile(Environment.getExternalStorageDirectory() + File.separator
                    + Environment.DIRECTORY_DCIM + File.separator + "WAVES.amr");

try {
       recorder.prepare();
       recorder.start();
} catch (IOException e) {
       Toast.makeText(topic_player_list_layout.this,"Unable to record",Toast.LENGTH_SHORT).show();
       return;
            }


The question is that the output of recorded audio file quality is not good as compared to default android voice recorder app or whatsApp/Telegram voice recorder.

What do you suggest? What can I do to improve the quality of recorded voices?

Upvotes: 1

Views: 2441

Answers (2)

Sbonelo
Sbonelo

Reputation: 684

You have to increase your audioEncodingBitRate

MediaRecorder recorder=new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setAudioEncodingBitRate(128000);
recorder.setAudioSamplingRate(44100);

Upvotes: 4

gi097
gi097

Reputation: 7703

If we take a look at the documentation: https://developer.android.com/reference/android/media/MediaRecorder.OutputFormat, we can see that there are plenty of audio formats available. You are using THREE_GPP which does not deliver the best quality as far as I know. I would consider using MPEG_4 instead. Also try to use AAC instead of AMR as audio encoder.

Also take a look at this answer for more reference: https://stackoverflow.com/a/14973295/5457878

Upvotes: 6

Related Questions