alphacep / vosk-api

Offline speech recognition API for Android, iOS, Raspberry Pi and servers with Python, Java, C# and Node
Apache License 2.0
7.37k stars 1.04k forks source link

Vosk long loading time when cell is stopped prints: "error loading waveform" #1499

Closed Rahil8533 closed 4 months ago

Rahil8533 commented 6 months ago

I have been trying to use vosk however it keeps loading without printing output in jupyter notebook here is my code: from vosk import Model, KaldiRecognizer import os import queue import vosk import sys import json import wave model_dir="./vosk-model-en-us-0.22" if not os.path.exists(model_dir): print ("Please download a model for your language from https://alphacephei.com/vosk/models") print ("and unpack as "+model_dir+"' in the current folder.")

sys.exit(0)

model = vosk.Model(model_dir)

with wave.open("Audio_Files/EN/checkin.wav") as wf:

with wave.open("./checkin.wav") as wf: assert wf.getnchannels() == 1, "must be a mono wav" assert wf.getsampwidth() == 2, "must be a 16bit wav" assert wf.getcomptype() == "NONE", "must be PCM data"

wf.getnframes()

rec = vosk.KaldiRecognizer(model, wf.getframerate())
while True:
    data = wf.readframes(4000)
    if rec.AcceptWaveform(data):
        res = json.loads(rec.Result())
        print(res["text"])

I have tried the vosk-model-small-en-us-0.15 model as well with the same result

nshmyrev commented 5 months ago

You'd better show a screenshot with the problem

nshmyrev commented 4 months ago

Let us know if you need extra help