I'm trying to do ASR speech to text transcription using the VOSK API, I have downloaded all the required models and and imported the required modules however my transcription simply does not load here is my code below
from vosk import Model, KaldiRecognizer
import os
import queue
import vosk
import sys
import json
import wave
model_dir="data/raw/vosk-model-small-en-us-0.15"
model = vosk.Model(model_dir)
# For a smaller download size, use model = Model(model_name="vosk-model-small-en-us-0.15")
#with wave.open("Audio_Files/EN/checkin.wav") as wf:
with wave.open("Audio_Files/EN/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"
rec = vosk.KaldiRecognizer(model, wf.getframerate())
while True:
data = wf.readframes(4000)
if rec.AcceptWaveform(data):
res = json.loads(rec.Result())
print(res["text"])