alphacep / alphacep/vosk-api

Failing to load vosk model

Abierto
#1,739 1 comentario 2 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Jupyter Notebook
Estrellas
15.1k
Forks
1.8k
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I have already downloaded vosk-model-en-us-0.22 on Ubuntu22.04, but the output is stuck at the log file message
```ruby
LOG (VoskAPI:ReadDataFiles():model.cc:213) Decoding params beam=13 max-active=7000 lattice-beam=6
LOG (VoskAPI:ReadDataFiles():model.cc:216) Silence phones 1:2:3:4:5:11:12:13:14:15
LOG (VoskAPI:RemoveOrphanNodes():nnet-nnet.cc:948) Removed 0 orphan nodes.
LOG (VoskAPI:RemoveOrphanComponents():nnet-nnet.cc:847) Removing 0 orphan components.
LOG (VoskAPI:ReadDataFiles():model.cc:248) Loading i-vector extractor from vosk-model-en-us-0.22_planb/ivector/final.ie
LOG (VoskAPI:ComputeDerivedVars():ivector-extractor.cc:183) Computing derived variables for iVector extractor
LOG (VoskAPI:ComputeDerivedVars():ivector-extractor.cc:204) Done.
LOG (VoskAPI:ReadDataFiles():model.cc:279) Loading HCLG from vosk-model-en-us-0.22_planb/graph/HCLG.fst
LOG (VoskAPI:ReadDataFiles():model.cc:297) Loading words from vosk-model-en-us-0.22_planb/graph/words.txt
LOG (VoskAPI:ReadDataFiles():model.cc:308) Loading winfo vosk-model-en-us-0.22_planb/graph/phones/word_boundary.int
LOG (VoskAPI:ReadDataFiles():model.cc:315) Loading subtract G.fst model from vosk-model-en-us-0.22_planb/rescore/G.fst
LOG (VoskAPI:ReadDataFiles():model.cc:317) Loading CARPA model from vosk-model-en-us-0.22_planb/rescore/G.carpa
LOG (VoskAPI:ReadDataFiles():model.cc:323) Loading RNNLM model from /home/dictmanage/.cache/vosk/vosk-model-en-us-0.22/rnnlm/final.raw
```
and my jupyter kernel sometimes dies after the log message was output:

> Kernel Restarting
The kernel for Wav输出.ipynb appears to have died. It will restart automatically.

I have checked and ensured that the memory is enough to load the model of 16gb
and my code is basically the same as the example code provided.
```ruby
import wave
import sys
from vosk import Model, KaldiRecognizer, SetLogLevel
SetLogLevel(0)
wf = wave.open('text.wav', "rb")
if wf.getnchannels() != 1 or wf.getsampwidth() != 2 or wf.getcomptype() != "NONE":
print("Audio file must be WAV format mono PCM.")
sys.exit(1)
model = Model("vosk-model-en-us-0.22")
rec = KaldiRecognizer(model, wf.getframerate())
rec.SetWords(True)
rec.SetPartialWords(True)
result=[]
while True:
data = wf.readframes(4000)
if len(data) == 0:
break
if rec.AcceptWaveform(data):
print(rec.Result())
with open("output.json", "w", encoding="utf-8") as f:
json.dump(rec.Result()['result'], f, ensure_ascii=False, indent=4)
```

It is confusing that when I downloaded the model, the code above ran perfectly fine and had proper output, but when I ran the same code later on, it always got stuck around the log message above.
And rarely, when I run this block of code 20 times, there may be 1 time when something different would be output:
```ruby
ERROR (VoskAPI:ReadSparseWordFeatures():rnnlm-utils.cc:53) No value for feature-index 6837
Traceback (most recent call last):
File "/home/dictmanage/miniconda3/envs/MinerU6/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3579, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "/tmp/ipykernel_565537/4006666277.py", line 19, in
model = Model(model_name="vosk-model-en-us-0.22")
File "/home/dictmanage/miniconda3/envs/MinerU6/lib/python3.10/site-packages/vosk/__init__.py", line 57, in __init__
raise Exception("Failed to create a model")
Exception: Failed to create a model
```
I really have no idea what's wrong.

P.S. If I use default model

> model = Model(lang="en-us")

Everything works fine.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.