daanzu / kaldi-active-grammar

Python Kaldi speech recognition with grammars that can be set active/inactive dynamically at decode-time
GNU Affero General Public License v3.0
337 stars 50 forks source link

Error switching to new model #11

Closed mrob95 closed 4 years ago

mrob95 commented 4 years ago

Hi, just tried upgrading to the new (medium) model and I'm getting the following error message as soon as recognition begins. I'm on the latest versions and this grammar works fine on the zamia model. I've tried grepping a_I and it isn't coming from my files I don't think.

Traceback (most recent call last):
  File "kaldi_module_loader_medium.py", line 162, in <module>
    main()
  File "kaldi_module_loader_medium.py", line 140, in main
    engine.connect()
  File "C:\ProgramData\Anaconda3\lib\site-packages\dragonfly\engines\backend_kaldi\engine.py", line 132, in connect
    cloud_dictation_lang=self._options['cloud_dictation_lang'],
  File "C:\ProgramData\Anaconda3\lib\site-packages\dragonfly\engines\backend_kaldi\compiler.py", line 73, in __init__
    KaldiAGCompiler.__init__(self, model_dir=model_dir, tmp_dir=tmp_dir, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\kaldi_active_grammar\compiler.py", line 194, in __init__
    self.model = Model(model_dir, tmp_dir)
  File "C:\ProgramData\Anaconda3\lib\site-packages\kaldi_active_grammar\model.py", line 198, in __init__
    self.generate_lexicon_files()
  File "C:\ProgramData\Anaconda3\lib\site-packages\kaldi_active_grammar\model.py", line 279, in generate_lexicon_files
    generate_file('align_lexicon.int', lambda word, word_id, phones:
  File "C:\ProgramData\Anaconda3\lib\site-packages\kaldi_active_grammar\model.py", line 275, in generate_file
    file.write(write_func(word, word_id, phones) + '\n')
  File "C:\ProgramData\Anaconda3\lib\site-packages\kaldi_active_grammar\model.py", line 280, in <lambda>
    str_space_join([word_id, word_id] + [self.phone_to_int_dict[phone] for phone in phones]))
  File "C:\ProgramData\Anaconda3\lib\site-packages\kaldi_active_grammar\model.py", line 280, in <listcomp>
    str_space_join([word_id, word_id] + [self.phone_to_int_dict[phone] for phone in phones]))
KeyError: 'a_I'

Let me know if you need any more details :) thanks

Edit: https://github.com/daanzu/kaldi-active-grammar/commit/892ab77b624ae9446d106fb60114d68d69220be9 maybe the fix for this? I tried to update to the latest but there is an assert statement in
the dragonfly engine code which fails on the dev version

daanzu commented 4 years ago

Yeah, I think that should fix it, but I was afraid to post a point release without further testing, and I forgot that the backend would fail on a dev version. For the time being, you can safely delete lines 72-82 in /dragonfly/engines/backend_kaldi/engine.py. Let me know if it works!

daanzu commented 4 years ago

Should be fixed now in 1.3.0 and the upcoming version of dragonfly.