Reputation: 41
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:
X.X.X
.ffmpeg
).The response always returns None
without any exceptions. Any ideas on what could be going wrong?
Upvotes: 0
Views: 257
Reputation: 41
The maximum file size for the OpenAI Whisper model is 25 MB, and the maximum duration is 30 seconds. Check the audio file, if it does exceed 25 MB, break it into chunks and send.
Upvotes: 0