stash commit - wip

This commit is contained in:
2026-06-25 00:30:59 +03:00
parent 3d48f473b0
commit 5cb7b14705
12 changed files with 102 additions and 26 deletions
+53
View File
@@ -0,0 +1,53 @@
from transcription.engines.BaseEngine import BaseEngine
import wave, json
from vosk import Model, KaldiRecognizer
"""
import wave
import json
import sys
from multiprocessing.dummy import Pool
from vosk import Model, KaldiRecognizer
model = Model("en-us")
def recognize(line):
uid, fn = line.split()
wf = wave.open(fn, "rb")
rec = KaldiRecognizer(model, wf.getframerate())
text = ""
while True:
data = wf.readframes(1000)
if len(data) == 0:
break
if rec.AcceptWaveform(data):
jres = json.loads(rec.Result())
text = text + " " + jres["text"]
jres = json.loads(rec.FinalResult())
text = text + " " + jres["text"]
return uid + text
def main():
p = Pool(8)
texts = p.map(recognize, open(sys.argv[1], encoding="utf-8").readlines())
print ("\n".join(texts))
main()
"""
class VoskEngine(BaseEngine):
TARGET_SAMPLING_RATE = 16000
def loadModel(self) -> None:
...
def unloadModel(self) -> None:
...
def transcribeBatch(
self,
batch,
) -> str:
...