vosk-api icon indicating copy to clipboard operation
vosk-api copied to clipboard

Exception: ConstArpaLm section reading failed

Open MatheusGysi opened this issue 2 years ago • 21 comments

I'm tring to load vosk-model-pt-fb-v0.1.1-20220516_2113 but i keep receving this error:

---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
c:\NPS\Speech_recognition\vosk\vosk_test.ipynb Cell 4' in <cell line: 1>()
----> [1](vscode-notebook-cell:/c%3A/NPS/Speech_recognition/vosk/vosk_test.ipynb#ch0000006?line=0) model.recognize_vosk(audio)

File c:\Users\OI417144\Anaconda3\envs\Speech\lib\site-packages\speech_recognition\__init__.py:1677, in Recognizer.recognize_vosk(self, audio_data, language)
   [1675](file:///c%3A/Users/OI417144/Anaconda3/envs/Speech/lib/site-packages/speech_recognition/__init__.py?line=1674)         return "Please download the model from https://github.com/alphacep/vosk-api/blob/master/doc/models.md and unpack as 'model' in the current folder."
   [1676](file:///c%3A/Users/OI417144/Anaconda3/envs/Speech/lib/site-packages/speech_recognition/__init__.py?line=1675)         exit (1)
-> [1677](file:///c%3A/Users/OI417144/Anaconda3/envs/Speech/lib/site-packages/speech_recognition/__init__.py?line=1676)     self.vosk_model = Model("model")
   [1679](file:///c%3A/Users/OI417144/Anaconda3/envs/Speech/lib/site-packages/speech_recognition/__init__.py?line=1678) rec = KaldiRecognizer(self.vosk_model, 16000);
   [1681](file:///c%3A/Users/OI417144/Anaconda3/envs/Speech/lib/site-packages/speech_recognition/__init__.py?line=1680) rec.AcceptWaveform(audio_data.get_raw_data(convert_rate=16000, convert_width=2));

File c:\Users\OI417144\Anaconda3\envs\Speech\lib\site-packages\vosk\__init__.py:53, in Model.__init__(self, model_path, model_name, lang)
     [51](file:///c%3A/Users/OI417144/Anaconda3/envs/Speech/lib/site-packages/vosk/__init__.py?line=50)     self._handle = _c.vosk_model_new(model_path.encode('utf-8'))
     [52](file:///c%3A/Users/OI417144/Anaconda3/envs/Speech/lib/site-packages/vosk/__init__.py?line=51) if self._handle == _ffi.NULL:
---> [53](file:///c%3A/Users/OI417144/Anaconda3/envs/Speech/lib/site-packages/vosk/__init__.py?line=52)     raise Exception("Failed to create a model")

Exception: Failed to create a mode

When I try with other models: small-pt, small-en-us-0.15,en-us-0.22, works fine.

MatheusGysi avatar Jun 02 '22 17:06 MatheusGysi

I've just tried it and it works fine. Please try to download the file again, maybe it was corrupted.

nshmyrev avatar Jun 02 '22 22:06 nshmyrev

I've just tried it and it works fine. Please try to download the file again, maybe it was corrupted.

I have 16GB Ram and I have redownloaded the model again, still doesn't work.

MFRS avatar Jul 27 '22 11:07 MFRS

@MFRS please provide the full command output

nshmyrev avatar Jul 27 '22 11:07 nshmyrev

LOG (VoskAPI:ReadDataFiles():model.cc:213) Decoding params beam=10 max-active=7000 lattice-beam=6 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 C:\PathPrograms\vosk-model-pt-fb-v0.1.1-20220516_2113/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 C:\PathPrograms\vosk-model-pt-fb-v0.1.1-20220516_2113/graph/HCLG.fst LOG (VoskAPI:ReadDataFiles():model.cc:294) Loading words from C:\PathPrograms\vosk-model-pt-fb-v0.1.1-20220516_2113/graph/words.txt LOG (VoskAPI:ReadDataFiles():model.cc:303) Loading winfo C:\PathPrograms\vosk-model-pt-fb-v0.1.1-20220516_2113/graph/phones/word_boundary.int LOG (VoskAPI:ReadDataFiles():model.cc:310) Loading subtract G.fst model from C:\PathPrograms\vosk-model-pt-fb-v0.1.1-20220516_2113/rescore/G.fst LOG (VoskAPI:ReadDataFiles():model.cc:312) Loading CARPA model from C:\PathPrograms\vosk-model-pt-fb-v0.1.1-20220516_2113/rescore/G.carpa ERROR (VoskAPI:ReadInternal():const-arpa-lm.cc:610) ConstArpaLm <LmStates> section reading failed. Traceback (most recent call last): File "c:\Users\main.py", line 17, in <module> generator() File "c:\Users\Generator.py", line 75, in main model = Model(model_path) File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\vosk\__init__.py", line 53, in __init__ raise Exception("Failed to create a model") Exception: Failed to create a model

MFRS avatar Jul 27 '22 11:07 MFRS

It should print more messages from the start

nshmyrev avatar Jul 27 '22 11:07 nshmyrev

It should print more messages from the start

I updated my previous comment.

MFRS avatar Jul 27 '22 11:07 MFRS

Do you have 32-bit python by chance? What is the output of python script:

import platform
print(platform.architecture())

nshmyrev avatar Jul 27 '22 11:07 nshmyrev

import platform print(platform.architecture())

Python 3.10.5 (tags/v3.10.5:f377153, Jun 6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)] on win32

MFRS avatar Jul 27 '22 11:07 MFRS

Does other big model work for you like https://alphacephei.com/vosk/models/vosk-model-de-0.21.zip ?

nshmyrev avatar Jul 27 '22 12:07 nshmyrev

Does other big model work for you like https://alphacephei.com/vosk/models/vosk-model-de-0.21.zip ?

The vosk-model-en-us-0.22 works for me.

MFRS avatar Jul 27 '22 12:07 MFRS

Please check if https://alphacephei.com/vosk/models/vosk-model-de-0.21.zip works for you.

nshmyrev avatar Jul 27 '22 12:07 nshmyrev

Please check if https://alphacephei.com/vosk/models/vosk-model-de-0.21.zip works for you.

Will do, I'll update you soon.

MFRS avatar Jul 27 '22 12:07 MFRS

Please check if https://alphacephei.com/vosk/models/vosk-model-de-0.21.zip works for you.

I tried it and it worked.

MFRS avatar Jul 27 '22 12:07 MFRS

Please try

https://alphacephei.com/vosk/models/vosk-model-pt-fb-v0.1.1-pruned.zip

nshmyrev avatar Jul 28 '22 00:07 nshmyrev

Please try

https://alphacephei.com/vosk/models/vosk-model-pt-fb-v0.1.1-pruned.zip

This works for me, thank you very much for your support.

MFRS avatar Jul 28 '22 09:07 MFRS

I am getting the same error as @MFRS when using vosk-model-de-tuda-0.6-900k as seen below. Python and the modules seem to be up to date. Am I missing something?

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:6:7:8:9:10
LOG (VoskAPI:RemoveOrphanNodes():nnet-nnet.cc:948) Removed 1 orphan nodes.
LOG (VoskAPI:RemoveOrphanComponents():nnet-nnet.cc:847) Removing 2 orphan components.
LOG (VoskAPI:Collapse():nnet-utils.cc:1488) Added 1 components, removed 2
LOG (VoskAPI:ReadDataFiles():model.cc:248) Loading i-vector extractor from vosk/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/graph/HCLG.fst
LOG (VoskAPI:ReadDataFiles():model.cc:297) Loading words from vosk/graph/words.txt
LOG (VoskAPI:ReadDataFiles():model.cc:308) Loading winfo vosk/graph/phones/word_boundary.int
LOG (VoskAPI:ReadDataFiles():model.cc:315) Loading subtract G.fst model from vosk/rescore/G.fst
LOG (VoskAPI:ReadDataFiles():model.cc:317) Loading CARPA model from vosk/rescore/G.carpa
ERROR (VoskAPI:ReadInternal():const-arpa-lm.cc:610) ConstArpaLm <LmStates> section reading failed.
Traceback (most recent call last):
File "C:\Users\user\Desktop\Interviews\transcript.py", line 11, in
model = Model("vosk") ^^^^^^^^^^^^^ File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\vosk_init_.py", line 57, in init raise Exception("Failed to create a model") Exception: Failed to create a model

FalconEye369 avatar Jan 17 '23 00:01 FalconEye369

Simply use our model instead

nshmyrev avatar Jan 17 '23 01:01 nshmyrev

Please try

https://alphacephei.com/vosk/models/vosk-model-pt-fb-v0.1.1-pruned.zip

I had the same problem as above today, your model fixed my problem. Thank kindly.

ShanksPhysics avatar Apr 30 '23 02:04 ShanksPhysics

Please try

https://alphacephei.com/vosk/models/vosk-model-pt-fb-v0.1.1-pruned.zip

I had the same problem on windows, but only with the model vosk-model-pt-fb-v0.1.1-20220516_2113 even larger models I had no problem, is the one you sent because it is smaller less efficient than the original?

GladistonXD avatar Aug 09 '23 02:08 GladistonXD

@nshmyrev I think I have the same issue with the Russian models on Windows x32. Tried to use all four models from the list but only the small model works. With other ones, I have similar outputs. Can I solve it somehow?

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: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 ./vosk-model-ru-0.10/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-ru-0.10/graph/HCLG.fst
LOG (VoskAPI:ReadDataFiles():model.cc:294) Loading words from ./vosk-model-ru-0.10/graph/words.txt
LOG (VoskAPI:ReadDataFiles():model.cc:303) Loading winfo ./vosk-model-ru-0.10/graph/phones/word_boundary.int
LOG (VoskAPI:ReadDataFiles():model.cc:310) Loading subtract G.fst model from ./vosk-model-ru-0.10/rescore/G.fst
LOG (VoskAPI:ReadDataFiles():model.cc:312) Loading CARPA model from ./vosk-model-ru-0.10/rescore/G.carpa
Traceback (most recent call last):
  File "c:/Users/workm/source/repos/TEST_PROJECTS/electron-voice-video/recognition-server/server.py", line 7, in <module>
    model = Model(model_path="./vosk-model-ru-0.10")
  File "C:\Users\workm\AppData\Local\Programs\Python\Python38-32\lib\site-packages\vosk\__init__.py", line 57, in __init__
    raise Exception("Failed to create a model")
Exception: Failed to create a model

VladislavMaksimov avatar Dec 01 '23 16:12 VladislavMaksimov

@nshmyrev I think I have the same issue with the Russian models on Windows x32. Tried to use all four models from the list but only the small model works. With other ones, I have similar outputs. Can I solve it somehow?

Big models require 16Gb of memory and won't fit x32. You can remove rescore and rnnlm folders from the model to make it smaller, probably it will load then.

nshmyrev avatar Dec 02 '23 17:12 nshmyrev