#whisper not seeing correct file type

1 messages · Page 1 of 1 (latest)

sudden tundra
#

I'm trying to use the whisper api to make a simple transcription app with flask ```python
@app.route('/transcribe', methods=['POST'])
def transcribe_audio():
audio_file = request.files['audio']
response = client.audio.transcriptions.create(
model='whisper-1',
file=audio_file,
language=LANG
)
return jsonify(response)

``RuntimeError: Expected entry at `file` to be bytes, an io.IOBase instance, PathLike or a tuple but received <class 'werkzeug.datastructures.file_storage.FileStorage'> instead. See https://github.com/openai/openai-python/tree/main#file-uploads``
when I change it to bytes: ```python
    audio_file = request.files['audio']
    audio_bytes = io.BytesIO()
    audio_file.save(audio_bytes)
    audio_bytes.seek(0)
    response = client.audio.transcriptions.create(
        model='whisper-1', 
        file=audio_bytes,
        language=LANG
    )
```, I still get an error ``openai.BadRequestError: Error code: 400 - {'error': {'message': "Unrecognized file format. Supported formats: ['flac', 'm4a', 'mp3', 'mp4', 'mpeg', 'mpga', 'oga', 'ogg', 'wav', 'webm']", 'type': 'invalid_request_error', 'param': None, 'code': None}}``
I'm pretty sure that the browser is sending the right data to the flask app. but why is whisper not saying it is correct. help would be greatly appreciated! I saw this forum post, but it didn't really help me that much <https://community.openai.com/t/whisper-api-cannot-read-files-correctly/93420/1>