# tools/audio_transcriber.py import os import tempfile import whisper # Load Whisper model only once (tiny, base, or small recommended for speed) MODEL_NAME = "base" whisper_model = whisper.load_model(MODEL_NAME) def transcribe_audio(audio_file_path: str) -> str: """ Transcribes speech from an audio file using OpenAI Whisper. Args: audio_file_path (str): Path to the local audio file (.mp3, .wav, etc.). Returns: str: Transcribed text or error message. """ try: result = whisper_model.transcribe(audio_file_path) return result["text"].strip() except Exception as e: return f"Transcription error: {str(e)}"