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.57k stars 1.06k forks source link

Python program crashes after switching models #1337

Open project-owner opened 1 year ago

project-owner commented 1 year ago

After switching from one model to another and recreating the recognizer the program crashes with message: ASSERTIONFAILED (VoskAPI:ProcessNonemitting():lattice-incremental-decoder.cc:794) Assertion failed: (queue.empty()) Is there any way to fix that? Thanks!

goldyfruit commented 1 year ago

Facing the same behaviour with Python 3.11 and vosk-model-small-en-us-0.15/graph/phones/word_boundary.int.

ASSERTION_FAILED (VoskAPI:ProcessNonemitting():lattice-incremental-decoder.cc:794) Assertion failed: (queue_.empty())

Here is how VOSK is loaded.

LOG (VoskAPI:ReadDataFiles():model.cc:213) Decoding params beam=10 max-active=3000 lattice-beam=2
LOG (VoskAPI:ReadDataFiles():model.cc:216) Silence phones 1:2:3:4:5:6:7:8:9:10
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 /home/ovos/.local/share/vosk/vosk-model-small-en-us-0.15/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:282) Loading HCL and G from /home/ovos/.local/share/vosk/vosk-model-small-en-us-0.15/graph/HCLr.fst /home/ovos/.local/share/vosk/vosk-model-small-en-us-0.15/graph/Gr.fst
LOG (VoskAPI:ReadDataFiles():model.cc:308) Loading winfo /home/ovos/.local/share/vosk/vosk-model-small-en-us-0.15/graph/phones/word_boundary.int
nshmyrev commented 1 year ago

Do you have an audio file and a code sample to reproduce the problem please?

goldyfruit commented 1 year ago

Do you have an audio file and a code sample to reproduce the problem please?

sample.wav.gz

It happens only when using the stream feature from there: https://github.com/OpenVoiceOS/ovos-stt-plugin-vosk/blob/dev/ovos_stt_plugin_vosk/__init__.py#L165-L240

nshmyrev commented 1 year ago

Do you have an audio file and a code sample to reproduce the problem please?

sample.wav.gz

It happens only when using the stream feature from there: https://github.com/OpenVoiceOS/ovos-stt-plugin-vosk/blob/dev/ovos_stt_plugin_vosk/__init__.py#L165-L240

From the code it seems you create only one recognizer and use it in many threads, you should create new recognizer in every thread instead.

goldyfruit commented 1 year ago

Thanks @nshmyrev