0

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?

Valdi_Bo
  • 30,023
  • 4
  • 23
  • 41
amir ghorbani
  • 123
  • 2
  • 3
  • 10

2 Answers2

4

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

gi097
  • 7,313
  • 3
  • 27
  • 49
3

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);
Sbonelo
  • 664
  • 1
  • 9
  • 25