Skip to content

Commit

Permalink
Merge pull request #2684 from dimagi/fix_audio_recording_widget
Browse files Browse the repository at this point in the history
Set audio recorder sample rate
  • Loading branch information
avazirna committed Jul 28, 2023
2 parents a287cf2 + d58180b commit fb21463
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/src/org/commcare/views/widgets/RecordingFragment.java
Expand Up @@ -52,6 +52,9 @@ public class RecordingFragment extends DialogFragment {

private static final String MIMETYPE_AUDIO_AAC = "audio/mp4a-latm";

private static final int HEAAC_SAMPLE_RATE = 44100;
private static final int AMRNB_SAMPLE_RATE = 8000;

private String fileName;
private static final String FILE_EXT = ".mp3";

Expand Down Expand Up @@ -192,10 +195,13 @@ private void setupRecorder() {
recorder = new MediaRecorder();
}

boolean isHeAacSupported = isHeAacEncoderSupported();

recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setAudioSamplingRate(isHeAacSupported ? HEAAC_SAMPLE_RATE : AMRNB_SAMPLE_RATE);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setOutputFile(fileName);
if (isHeAacEncoderSupported()) {
if (isHeAacSupported) {
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.HE_AAC);
} else {
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
Expand Down

0 comments on commit fb21463

Please sign in to comment.