Spaces:
Runtime error
Runtime error
File size: 552 Bytes
2b83054 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import whisper
import os
class SpeechRecognizer:
def __init__(self, model_size="base"):
self.model = whisper.load_model(model_size)
def transcribe(self, audio_path, language="en"):
"""Transcribe audio file with timestamps"""
# Get results with word timestamps
result = self.model.transcribe(
audio_path,
language=language,
word_timestamps=False,
verbose=False
)
# Return segments with timestamps
return result["segments"] |