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.73k stars 1.08k forks source link

`Exception: Failed to create a model` when using `BatchModel` #1269

Open sadrasabouri opened 1 year ago

sadrasabouri commented 1 year ago

Description

I wanted to test inference on GPU with BatchModel. So I started by downloading vosk-model-en-us-0.22.zip and extracting it in a directory named model in the same directory where python/example/test* are.

While using the test_simple works fine for this model

python test_simple.py test.wav

Using the test_gpu_batch yields the following error:

Traceback (most recent call last):
  File "test_gpu_batch.py", line 13, in <module>
    model = BatchModel("model")
  File "/home/sadra/image-captioning/.venv/lib/python3.8/site-packages/vosk/__init__.py", line 243, in __init__
    raise Exception("Failed to create a model")
Exception: Failed to create a model

I wanted to know what can I do to make it work

Environment Details

Minor Notes

nshmyrev commented 1 year ago

What is the full output on console, it should print some messages above unless you disabled logging with SetLogLevel?

sadrasabouri commented 1 year ago

I tried it by importing SetLogLevel and setting the log level to 0, but the output is still the same. That's Odd.

nshmyrev commented 1 year ago

Maybe you compiled Vosk without CUDA? Seems like that. It returns NULL if no cuda enabled in Makefile

sadrasabouri commented 1 year ago

Thanks. I will check it and update this thread.

Dreamupers commented 1 year ago

The same problem

BatchModel("./vosk-model-cn-0.22/")

    240 self._handle = _c.vosk_batch_model_new(model_path.encode('utf-8'))
    242 if self._handle == _ffi.NULL:
--> 243     raise Exception("Failed to create a model")

Exception: Failed to create a model
nshmyrev commented 1 year ago

@Dreamupers and what is the log output

yujian340 commented 7 months ago

The same problem. JAVA-8, vosk-0.3.32

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:CompileLooped():nnet-compile-looped.cc:345) Spent 0.293582 seconds in looped compilation.
LOG (VoskAPI:ReadDataFiles():model.cc:248) Loading i-vector extractor from D:/java/vosk-models/vosk-model-cn-0.22/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:278) Loading HCLG from D:/java/vosk-models/vosk-model-cn-0.22/graph/HCLG.fst
LOG (VoskAPI:ReadDataFiles():model.cc:293) Loading words from D:/java/vosk-models/vosk-model-cn-0.22/graph/words.txt
LOG (VoskAPI:ReadDataFiles():model.cc:302) Loading winfo D:/java/vosk-models/vosk-model-cn-0.22/graph/phones/word_boundary.int
LOG (VoskAPI:ReadDataFiles():model.cc:309) Loading subtract G.fst model from D:/java/vosk-models/vosk-model-cn-0.22/rescore/G.fst
LOG (VoskAPI:ReadDataFiles():model.cc:311) Loading CARPA model from D:/java/vosk-models/vosk-model-cn-0.22/rescore/G.carpa
LOG (VoskAPI:ReadDataFiles():model.cc:317) Loading RNNLM model from D:/java/vosk-models/vosk-model-cn-0.22/rnnlm/final.raw
java.io.IOException: Failed to create a model
    at org.vosk.Model.<init>(Model.java:14)
    at com.ukefu.webim.util.server.handler.IMEventHandler.processFile(IMEventHandler.java:185)
    at com.ukefu.webim.util.server.handler.IMEventHandler.main(IMEventHandler.java:179)
nshmyrev commented 7 months ago

@yujian340 no, it is not the same problem, this issue is about GPU and BatchModel, your code is different

yujian340 commented 7 months ago

@yujian340不,这不是同一个问题,这个问题是关于GPU和BatchModel的,你的代码是不同的

sorry. my problem