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"]