Wisper API not recognizing .m4a file format

Here is the error from the response.

error: {
        message: "Invalid file format. Supported formats: ['m4a', 'mp3', 'webm', 'mp4', 'mpga', 'wav', 'mpeg']",
        type: 'invalid_request_error',
        param: null,
        code: null
      }

My audio file is named: text.m4a
Adding it to a form object:
formData.append("file", fs.createReadStream(filePath));

Why would the api call out invalid file format if my file is a .m4a?

1 Like

Hi @rickaz23

The error

type: 'invalid_request_error',

means there’s something wrong with the request, not necessarily the file format.

Feel free to share the code that calls the API in markdown, in order to help us solve the problem.

Here is the complete code.

const filePath = path.join('/', "test.m4a");
  const formData = new FormData();
  formData.append("file", fs.createReadStream(filePath)); 
  formData.append("model", "whisper-1");
  axios
    .post('https://api.openai.com/v1/audio/transcriptions', formData,{
      headers: {
        Authorization : `Bearer ${process.env.new_OPENAI_API_KEY}`,
        "Content-Type" : `multipart/form-data; boundary=${formData._boundary}`, 
      }
    })
    .then((res) =>{
      console.log(res.data);
    })

Not certain if it’s the case with you, but m4a files are notorious for having moov atoms at the end of the file (instead of beginning). Please verify whether that’s the case with your file. If you just want to somehow make it work without getting into the moov atom locating rabbit hole, then simply try:

ffmpeg -i input.m4a output.mp3     # or, even better, output.wav

…and then use the MP3 (or WAV) file instead of the M4A (MP3, among many other formats, is guaranteed to have moov atom at the start of the file). So if that was the reason for the issue, it should be fixed.

Quick Context:

1 Like

My experience with Whisper via the OpenAI API, is to send the full byte object of the audio file. Not sure if streams work. So you have to download the file to disc or memory, and send the full bytes in the request.

i have download m4a file into my local and try to pass audio file to whisper
model, i am facing ‘file not found in specific’ is that any reason i facing this error?