|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
from vosk import Model, SpkModel, KaldiRecognizer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BuscribeRecognizer(KaldiRecognizer):
|
|
|
|
|
class BuscribeRecognizer():
|
|
|
|
|
segments_start_time = None
|
|
|
|
|
|
|
|
|
|
def __init__(self, sample_rate=48000, model_path="model_small", spk_model_path="spk_model"):
|
|
|
|
@ -11,13 +11,23 @@ class BuscribeRecognizer(KaldiRecognizer):
|
|
|
|
|
|
|
|
|
|
Returns a recognizer object.
|
|
|
|
|
"""
|
|
|
|
|
self.sample_rate = sample_rate
|
|
|
|
|
self.model = Model(model_path)
|
|
|
|
|
self.spk_model = SpkModel(spk_model_path)
|
|
|
|
|
|
|
|
|
|
super(BuscribeRecognizer, self).__init__(self.model, sample_rate, self.spk_model)
|
|
|
|
|
self.recognizer = KaldiRecognizer(self.model, self.sample_rate, self.spk_model)
|
|
|
|
|
self.recognizer.SetWords(True)
|
|
|
|
|
|
|
|
|
|
self.SetWords(True)
|
|
|
|
|
|
|
|
|
|
def Reset(self):
|
|
|
|
|
super(BuscribeRecognizer, self).Reset()
|
|
|
|
|
def reset(self):
|
|
|
|
|
self.recognizer = KaldiRecognizer(self.model, self.sample_rate, self.spk_model)
|
|
|
|
|
self.recognizer.SetWords(True)
|
|
|
|
|
self.segments_start_time = None
|
|
|
|
|
|
|
|
|
|
def accept_waveform(self, data):
|
|
|
|
|
return self.recognizer.AcceptWaveform(data)
|
|
|
|
|
|
|
|
|
|
def result(self):
|
|
|
|
|
return self.recognizer.Result()
|
|
|
|
|
|
|
|
|
|
def final_result(self):
|
|
|
|
|
return self.recognizer.FinalResult()
|
|
|
|
|