alphacep / vosk-api

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

Exception: ConstArpaLm section reading failed #991

Open MatheusGysi opened 2 years ago

MatheusGysi commented 2 years ago

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.

nshmyrev commented 2 years ago

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

MFRS commented 2 years ago

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.

nshmyrev commented 2 years ago

@MFRS please provide the full command output

MFRS commented 2 years ago

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

nshmyrev commented 2 years ago

It should print more messages from the start

MFRS commented 2 years ago

It should print more messages from the start

I updated my previous comment.

nshmyrev commented 2 years ago

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

import platform
print(platform.architecture())
MFRS commented 2 years ago

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

nshmyrev commented 2 years ago

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

MFRS commented 2 years ago

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.

nshmyrev commented 2 years ago

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

MFRS commented 2 years ago

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 commented 2 years ago

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

I tried it and it worked.

nshmyrev commented 2 years ago

Please try

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

MFRS commented 2 years ago

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.

FalconEye369 commented 1 year ago

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 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

nshmyrev commented 1 year ago

Simply use our model instead

ShanksPhysics commented 1 year ago

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.

GladistonXD commented 1 year ago

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?

VladislavMaksimov commented 12 months ago

@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
nshmyrev commented 12 months ago

@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.

fdiego18 commented 3 months ago

Por favor tente

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

Obrigado amigo, você é um amigo.

GustavoKanaiama commented 3 months ago

Please try

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

Thanks bro🙏🙏

Glauber-Sc commented 2 months ago

Olá estou com problema. ERROR (VoskAPI:ReadInternal():const-arpa-lm.cc:610) ConstArpaLm section reading failed.

PS C:\Users\glaub\Desktop\AudioEmTexto_server> yarn start
yarn run v1.22.22 $ nodemon index.js [nodemon] 3.1.4 [nodemon] to restart at any time, enter rs
[nodemon] watching path(s): . [nodemon] watching extensions: js,mjs,cjs,json [nodemon] starting node index.js 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 model/vosk-model-pt-fb-v0.1.1-20220516_2113/ivector/final.ieLOG (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 model/vosk-model-pt-fb-v0.1.1-20220516_2113/graph/HCLG.fst LOG (VoskAPI:ReadDataFiles():model.cc:294) Loading words from model/vosk-model-pt-fb-v0.1.1-20220516_2113/graph/words.txt LOG (VoskAPI:ReadDataFiles():model.cc:303) Loading winfo model/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 model/vosk-model-pt-fb-v0.1.1-20220516_2113/rescore/G.fst LOG (VoskAPI:ReadDataFiles():model.cc:312) Loading CARPA model from model/vosk-model-pt-fb-v0.1.1-20220516_2113/rescore/G.carpa ERROR (VoskAPI:ReadInternal():const-arpa-lm.cc:610) ConstArpaLm section reading failed. Servidor rodando na porta 3000

Tem outro modelo que eu possa usar que seja o mais preciso possível ?

daresan commented 1 month ago

Please try

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

Hello! I also stumbled upon this error with the german vosk-model-de-tuda-0.6-900k, and also saw that you recommended this model instead in another issue about the german model, but the thing is, that this model is in portuguese and not german! Where can I get the fixed one in german? My RAM is 16GB and I am on a 64bit system.

nshmyrev commented 1 month ago

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

Hello! I also stumbled upon this error with the german vosk-model-de-tuda-0.6-900k, and also saw that you recommended this model instead in another issue about the german model, but the thing is, that this model is in portuguese and not german! Where can I get the fixed one in german? My RAM is 16GB and I am on a 64bit system.

https://alphacephei.com/vosk/models/vosk-model-de-0.21.zip

daresan commented 1 month ago

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

Hello! I also stumbled upon this error with the german vosk-model-de-tuda-0.6-900k, and also saw that you recommended this model instead in another issue about the german model, but the thing is, that this model is in portuguese and not german! Where can I get the fixed one in german? My RAM is 16GB and I am on a 64bit system.

https://alphacephei.com/vosk/models/vosk-model-de-0.21.zip

Hello! Thanks for your answer, but this model is a lot smaller and I would like to use a bigger one, since that one is not very good in recoginzing the sentence, I already tried it. Isn't it possible to use the bigger one? What's wrong with the bigger one? Best regards, Daniel

nshmyrev commented 1 month ago

What's wrong with the bigger one?

Windows does not support such big model files. You can try it in colab (Linux).