Whisper API file format error

I’m trying to use Whisper API and it worked when I upload my local audio file. Now when I try to develop it as an endpoint in FastAPI, the API would not accept the file, throwing an Invalid Request Error.

async def summarise_audio(file:UploadFile):
    audio =await file.read()

    with open("testy.wav",'wb') as f:
    x = open("testy.wav",'rb')
    transcript = openai.Audio.transcribe("whisper-1",x)
    # transcript = openai.Audio.transcribe("whisper-1",file.file)
    return transcript

It worked when I read the received file and save it into the disk and then opening it from disk.
But when I use the file directly from the endpoint, it is throwing InvalidRequestError

openai.error.InvalidRequestError: Invalid file format. Supported formats: ['m4a', 'mp3', 'webm', 'mp4', 'mpga', 'wav', 'mpeg'] 

Sounds like your error could be related to this post Whisper API cannot read files correctly - #20 by RePattern