File size: 651 Bytes
8ad2ab3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# 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"] |