Python Whisper Invalid File Format After API Error

When Whisper throws an API Error, I get a log like this

 The following exception was raised when running <function get_whisper_transcript at 0x7f36160489d0> APIError HTTP code 502 from API (<html> <head><title>502 Bad Gateway</title></head> <body> <center><h1>502 Bad Gateway</h1></center> <hr><center>cloudflare</center> </body> </html> ) attempt 0 of 6 with wait 1.0 sec(s)

Which ideally I could catch and retry, but the problem is immediately after I get an Invalid Request - invalid file format error

 error_code=None error_message="Invalid file format. Supported formats: ['m4a', 'mp3', 'webm', 'mp4', 'mpga', 'wav', 'mpeg']" error_param=None error_type=invalid_request_error message='OpenAI API error received' stream_error=False

which is not an error I typically want to catch and retry on. I know it’s not an actual issue with the file format because on rerun, I have no issues.

It seems like the API Error is not returning on Whisper stuff and it tries to continue which then throws the Invalid File Format Error. Anyone else having this issue?

2 Likes