File size: 274 Bytes
6ef31de
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
import whisper


class SpeechRecognizer:

    def __init__(self, device='cuda'):
        self.model = whisper.load_model('base').to(device)

    def __call__(self, video_path):
        generated_text = self.model.transcribe(video_path)['text']
        return generated_text