Updated archtecture, fixed dependencies
This commit is contained in:
parent
5ed98994e9
commit
964d25de86
179 changed files with 609 additions and 1365 deletions
30
stt.py
30
stt.py
|
|
@ -1,30 +0,0 @@
|
|||
import vosk
|
||||
import sys
|
||||
import sounddevice as sd
|
||||
import queue
|
||||
import json
|
||||
|
||||
model = vosk.Model("model_small")
|
||||
samplerate = 16000
|
||||
device = 2
|
||||
|
||||
q = queue.Queue()
|
||||
|
||||
|
||||
def q_callback(indata, frames, time, status):
|
||||
if status:
|
||||
print(status, file=sys.stderr)
|
||||
q.put(bytes(indata))
|
||||
|
||||
|
||||
def va_listen(callback):
|
||||
with sd.RawInputStream(samplerate=samplerate, blocksize=8000, device=device, dtype='int16',
|
||||
channels=1, callback=q_callback):
|
||||
|
||||
rec = vosk.KaldiRecognizer(model, samplerate)
|
||||
while True:
|
||||
data = q.get()
|
||||
if rec.AcceptWaveform(data):
|
||||
callback(json.loads(rec.Result())["text"])
|
||||
#else:
|
||||
# print(rec.PartialResult())
|
||||
Loading…
Add table
Add a link
Reference in a new issue