How to use the vosk.Model function in vosk

To help you get started, we’ve selected a few vosk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alphacep / vosk-api / python / example / test_local.py View on Github external
#!/usr/bin/python3

from vosk import Model, KaldiRecognizer
import sys
import json
import os

if not os.path.exists("model"):
    print ("Please download the model from https://github.com/alphacep/kaldi-android-demo/releases and unpack as 'model' in the current folder.")
    exit (1)


model = Model("model")
rec = KaldiRecognizer(model, 16000)

wf = open(sys.argv[1], "rb")
wf.read(44) # skip header

while True:
    data = wf.read(2000)
    if len(data) == 0:
        break
    if rec.AcceptWaveform(data):
        res = json.loads(rec.Result())
        print (res)
    else:
        res = json.loads(rec.PartialResult())
        print (res)

vosk

Offline open source speech recognition API based on Kaldi and Vosk

Apache-2.0
Latest version published 2 years ago

Package Health Score

64 / 100
Full package analysis

Popular vosk functions