Spaces:
Runtime error
Runtime error
File size: 372 Bytes
596821a |
1 2 3 4 5 6 7 8 9 10 11 12 |
import whisper
import tempfile
# Transcribe uploaded audio file to text using Whisper
def transcribe_audio(audio_file) -> str:
model = whisper.load_model("base")
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp:
tmp.write(audio_file.read())
tmp_path = tmp.name
result = model.transcribe(tmp_path)
return result["text"]
|