hyochan / react-native-audio-recorder-player

react-native native module for audio recorder and player.
MIT License
681 stars 203 forks source link

AMR or AMR_WB encoded recording on Android? #568

Open Raccoonrider opened 8 months ago

Raccoonrider commented 8 months ago

I'm trying to record audio for Google Speech-to-Text engine on Android.

I looked through the docs on configuration available here: https://github.com/hyochan/react-native-audio-recorder-player#able-to-customize-recorded-audio-quality-from-230

It looks like two of the configurable options are supported by Google Speech-to-Text: AMR 8000Hz mono and AMR_WB 16000Hz mono.

However, when I try the following config, I get a file as AAC LC 48000Hz stereo:

const audioSet: AudioSet = {
  AVSampleRateKeyIOS: 16000,
  AudioEncoderAndroid: AudioEncoderAndroidType.AMR_WB,
  AudioSourceAndroid: AudioSourceAndroidType.MIC,
  AVModeIOS: AVModeIOSOption.measurement,
  AVEncoderAudioQualityKeyIOS: AVEncoderAudioQualityIOSType.high,
  AVNumberOfChannelsKeyIOS: 1,
  AVFormatIDKeyIOS: AVEncodingOption.AMR_WB,
};

Am I using thie AudioSet incorrectly? Is it currently possible to record AMR/AMR_WB, or should I just use ffmpeg-kit?

Thanks in advance!