Fast_api / transcribe.py
mulasagg's picture
Add application file
8ad2ab3
raw
history blame
651 Bytes
# using whisper to transcribe audio files
import whisper
import os
def transcribe_audio(file_path, model_size="base"):
"""
Transcribe audio file using Whisper model.
Args:
file_path (str): Path to the audio file.
model_size (str): Size of the Whisper model to use. Options are "tiny", "base", "small", "medium", "large".
Returns:
str: Transcription of the audio file.
"""
# Load the Whisper model
model = whisper.load_model(model_size)
# Transcribe the audio file
result = model.transcribe(file_path, fp16=False)
# Return the transcription
return result["text"]