So I am creating a simple website that takes in phone recording and transcribes them with WhisperAI API. I ran into this peculiar trouble where m4a audio files of phone recordings are not recognized as m4a by WhisperAI
error 400 “Invalid file format. Supported formats: [‘m4a’, ‘mp3’, ‘webm’, ‘mp4’, ‘mpga’, ‘wav’, ‘mpeg’]”
Stranger yet, if I convert the file to mp4 (or any other files) and convert it back to m4a, it then recognizes it as a valid file.
Here are some of my theories:
- The website uses Nextjs framework and axios, which causes audio file to be corrupted when sending the file directly from front end
counter: but why did it work after converting it back to m4a? Or why didn’t my function for filtering out invalid file formats not work?
‘’’
const { getRootProps, getInputProps } = useDropzone({
accept: ‘audio/mpeg, audio/mp3, audio/mp4, audio/m4a, audio/wav, audio/webm’,
onDrop: (acceptedFiles) => {
if (acceptedFiles.length > 0) {
const acceptedTypes = [
‘audio/mpeg’,
‘audio/mp3’,
‘audio/mp4’,
‘audio/m4a’,
‘audio/x-m4a’,
‘audio/wav’,
‘audio/webm’,
];
const file = acceptedFiles[0];
if (acceptedTypes.includes(file.type)) {
try {
setUploading(true);
setAudioFile(file);
setError(null);
setSearchTerm(‘’);
// send the file to the API
} catch (error) {
console.error(‘Error setting audio file:’, error);
setError(‘Error setting audio file: ’ + error.message);
}
} else {
console.error(‘Invalid file type:’, file.type);
setError(‘Invalid file type: ’ + file.type);
}
} else {
console.error(‘No file selected’);
setError(‘No file selected’);
setSearchTerm(’’);
}
},
});
‘’’ - the recording done by the call-recording application (Korean application called 후후 통화녹음) is problematic. Which I’m not sure how I could check it out since I have zero knowledge on how the audio files are supposed to work.
.
.
I’m not sure how to proceed from here so I would really appreciate any sort of feedbacks. Thanks in advance!