Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
await Audio.setAudioModeAsync({
playsInSilentModeIOS: true,
allowsRecordingIOS: true,
});
const recordOptions = {
android: {
extension: '.m4a',
outputFormat: Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_MPEG_4,
audioEncoder: Audio.RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AAC,
sampleRate: 44100,
numberOfChannels: 2,
bitRate: 128000,
},
ios: {
extension: '.wav',
audioQuality: Audio.RECORDING_OPTION_IOS_AUDIO_QUALITY_HIGH,
sampleRate: 8000,
numberOfChannels: 1,
linearPCMBitDepth: 16,
linearPCMIsBigEndian: false,
linearPCMIsFloat: true,
},
};
await recording.prepareToRecordAsync(recordOptions);
await recording.startAsync();
console.log('Recording');
await timeout(8000);
console.log('Done recording');
await recording.stopAndUnloadAsync();
let recordingFile = recording.getURI();
let result = await identify(recordingFile, defaultOptions);