mirror of
https://github.com/alphacep/vosk-api.git
synced 2026-03-23 00:01:25 +08:00
29 lines
595 B
Python
Executable File
29 lines
595 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
from vosk import Model, BatchRecognizer, GpuInit, GpuThreadInit
|
|
import sys
|
|
import os
|
|
import wave
|
|
|
|
GpuInit()
|
|
GpuThreadInit()
|
|
|
|
rec = BatchRecognizer()
|
|
|
|
fnames = open("tedlium.list").readlines()
|
|
fds = [open(x.strip(), "rb") for x in fnames]
|
|
ended = set()
|
|
while True:
|
|
for i, fd in enumerate(fds):
|
|
if i in ended:
|
|
continue
|
|
data = fd.read(8000)
|
|
if len(data) == 0:
|
|
rec.FinishStream(i)
|
|
ended.add(i)
|
|
else:
|
|
rec.AcceptWaveform(i, data)
|
|
rec.Results()
|
|
if len(ended) == len(fds):
|
|
break
|