File size: 377 Bytes
9f559c6 b666b7d 9f559c6 b666b7d 9f559c6 b666b7d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
import whisper
import torch
# Checking if NVIDIA GPU is available
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
# Load the Whisper model
model = whisper.load_model("base", device=DEVICE)
def transcribe_audio(file_path: str) -> str:
"""Transcribes the given audio file and returns the text."""
result = model.transcribe(file_path)
return result['text']
|