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.35k stars 1.04k forks source link

HCLG.fst is not usuful? #1575

Closed donaldos closed 1 month ago

donaldos commented 1 month ago

You want to apply a self-created model to VOSK. The structure of the model is am/final.mdl graph/HCLG.fst etc. However, looking at the original resource folder, it seems that the model is failing to load due to the presence of HCLr.fst Gr.fst in graph.

The model structure is as follows . |-- README |-- am | `-- final.mdl

|-- conf | |-- ivector_extractor.conf | |-- mfcc.conf | |-- online.conf | |-- online_cmvn.conf | `-- splice.conf

|-- graph | |-- HCLG.fst | |-- disambig_tid.int | |-- num_pdfs | |-- phones | | |-- align_lexicon.int | | |-- align_lexicon.txt | | |-- disambig.int | | |-- disambig.txt | | |-- optional_silence.csl | | |-- optional_silence.int | | |-- optional_silence.txt | | |-- silence.csl | | |-- word_boundary.int | | -- word_boundary.txt | |-- phones.txt |-- words.txt

-- ivector |-- final.dubm |-- final.ie |-- final.mat |-- global_cmvn.stats |-- online_cmvn.conf -- splice_opts

test_simply.py modelpath = '/mnt/prj/workspace.speech/vosk.testbed/models.enuma'

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

model = None try: model = Model(model_path=modelpath) except Exception as es: print(es)

When I run example/test_simply.py, I get the following error. ERROR (VoskAPI:Model():model.cc:122) Folder '/mnt/prj/workspace.speech/vosk.testbed/models.enuma' does not contain model files. Make sure you specified the model path properly in Model constructor. If you are not sure about relative path, use absolute path specification. Failed to create a model Traceback (most recent call last): File "/mnt/prj/workspace.speech/vosk.testbed/vosk-api/python/example/test_simple.py", line 31, in rec = KaldiRecognizer(model, wf.getframerate()) File "/mnt/prj/workspace.speech/vosk.testbed/voskenv/lib/python3.10/site-packages/vosk/init.py", line 147, in init self._handle = _c.vosk_recognizer_new(args[0]._handle, args[1]) AttributeError: 'NoneType' object has no attribute '_handle' Exception ignored in: <function KaldiRecognizer.del at 0x7f9c6c4b51b0> Traceback (most recent call last): File "/mnt/prj/workspace.speech/vosk.testbed/voskenv/lib/python3.10/site-packages/vosk/init.py", line 161, in del _c.vosk_recognizer_free(self._handle) AttributeError: 'KaldiRecognizer' object has no attribute '_handle'

Any ideas and advice would be appreciated.

nshmyrev commented 1 month ago

You'd better attach screenshot with your filesystem layout

donaldos commented 1 month ago
스크린샷 2024-05-20 13 21 24
nshmyrev commented 1 month ago

In what folder do you have this

nshmyrev commented 1 month ago

You don't have model.conf, it is required

donaldos commented 1 month ago

Thank you for your advices. And I copy model.conf and another file to custom model set. And I get a good result. Thank you a lot.

nshmyrev commented 1 month ago

Ok, good, let us know how it goes.