1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Why does OpenAI Whisper return "None"?

Discussão em 'Python' iniciado por Stack, Setembro 28, 2024 às 01:22.

  1. Stack

    Stack Membro Participativo

    I’m trying to transcribe an MP3 file using OpenAI’s Whisper model, but the transcriptions.create() method consistently returns None. I’ve tried different MP3 files, converted them to WAV, updated the OpenAI library, and added error handling, but I still can’t figure out the issue.

    Here’s my code:

    ```from openai import OpenAI
    client = OpenAI(
    api_key = "MYAPIKEY"
    )

    audio_file = open("speech.mp3", "rb")
    transcript = client.audio.transcriptions.create(
    file=audio_file,
    model="whisper-1",
    response_format="verbose_json",
    timestamp_granularities=["segment"]
    )

    print(transcript)```


    I’ve confirmed that:

    The API key is valid. I’m using OpenAI Python library version X.X.X. I’ve tested both MP3 and WAV formats. The MP3 file is valid (checked using ffmpeg). The response always returns None without any exceptions. Any ideas on what could be going wrong?

    Continue reading...

Compartilhe esta Página