So i trying to build the speech to text application in react-native for android i am using react-native-audio-recorder-player libary for recording and for storage RNFS, the audio is saving in the location but the voice is not coming, the code is given below
import RNFS from 'react-native-fs';
import AudioRecorderPlayer, {
AVEncoderAudioQualityIOSType,
AVEncodingOption,
AVModeIOSOption,
AudioEncoderAndroidType,
AudioSourceAndroidType,
OutputFormatAndroidType,
} from 'react-native-audio-recorder-player';
import { useState } from 'react';
import { Platform } from 'react-native';
const audioRecorderPlayer = new AudioRecorderPlayer();
audioRecorderPlayer.setSubscriptionDuration(0.1);
const useRecording = () => {
const [recording, setRecording] = useState(false);
const [recordingPath, setRecordingPath] = useState('');
const audioSet = {
AudioEncoderAndroid: AudioEncoderAndroidType.AAC,
AudioSourceAndroid: AudioSourceAndroidType.MIC,
AVModeIOS: AVModeIOSOption.measurement,
AVEncoderAudioQualityKeyIOS: AVEncoderAudioQualityIOSType.high,
AVNumberOfChannelsKeyIOS: 2,
AVFormatIDKeyIOS: AVEncodingOption.aac,
OutputFormatAndroid: OutputFormatAndroidType.AAC_ADTS,
};
const startRecording = async () => {
const dirs =
Platform.OS === 'ios'
? RNFS.DocumentDirectoryPath
: RNFS.ExternalDirectoryPath;
console.log('dir', dirs);
const path = Platform.select({
ios: `${dirs}hello.m4a`,
android: `${dirs}/hello.wav`,
}); // File name for your recording
console.log('Recorded File Path:', path);
const result = await audioRecorderPlayer.startRecorder(
path,
audioSet,
true,
);
console.log('result', result);
setRecording(true);
setRecordingPath(result);
};
const stopRecording = async () => {
const result = await audioRecorderPlayer.stopRecorder();
setRecording(false);
};
return {
startRecording,
stopRecording,
setRecording,
recording,
recordingPath,
}
};
export default useRecording;
i have tried the audio is not coming i am expecting to listen the audio