Grammar loading/unloading breaks during waking/sleeping with newer dragonfly versions
I'm using a customized version of dragonfly, as i need some adoptions for the neo2 keyboard layout. The requirement for dragonfly in caster is dragonfly2>=0.29.0. After switching to the latest version, the sleeping/waking functionality is broken. Whenever i put caster into sleep, the following error emerges and the process is killed.
engine (INFO): Loading grammar _recobs_grammar
Caster: Microphone is sleeping
Exception in thread Thread-1 (_reader_thread):
Traceback (most recent call last):
File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/usr/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/dragonfly/dragonfly/engines/backend_kaldi/audio.py", line 110, in _reader_thread
in_data, overflowed = self.stream.read(self.stream.blocksize)
File "/.venv/lib/python3.10/site-packages/sounddevice.py", line 1196, in read
_check(err)
File "/.venv/lib/python3.10/site-packages/sounddevice.py", line 2653, in _check
raise PortAudioError(errormsg, err)
sounddevice.PortAudioError: Stream is stopped [PaErrorCode -9983]
Traceback (most recent call last):
File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/dragonfly/dragonfly/__main__.py", line 509, in <module>
main()
File "/dragonfly/dragonfly/__main__.py", line 504, in main
return_code = func(args)
File "/dragonfly/dragonfly/__main__.py", line 246, in cli_cmd_load
_do_recognition(engine, args)
File "/dragonfly/dragonfly/__main__.py", line 156, in _do_recognition
engine.do_recognition()
File "/dragonfly/dragonfly/engines/base/engine.py", line 251, in do_recognition
self._do_recognition(*args, **kwargs)
File "/dragonfly/dragonfly/engines/backend_kaldi/engine.py", line 434, in _do_recognition
self.prepare_for_recognition() # Do any of this leftover, now that phrase is done
File "/dragonfly/dragonfly/engines/backend_kaldi/engine.py", line 332, in prepare_for_recognition
operation()
File "/dragonfly/dragonfly/engines/backend_kaldi/engine.py", line 246, in load
kaldi_rule.load(lazy=self._compiler.lazy_compilation)
File "/.venv/lib/python3.10/site-packages/kaldi_active_grammar/compiler.py", line 152, in load
if self.destroyed: raise KaldiError("Cannot use a KaldiRule after calling destroy()")
kaldi_active_grammar.KaldiError: Cannot use a KaldiRule after calling destroy()
I know that this error might be caused by changes to dragonfly or kaldi_active_grammar, but i'm not familiar with the code base and maybe you encountered this error already or know at first glance what is wrong here.
Thanks for looking into this!
Downgrading to dragonfly 0.35.0 resolved the issue for me. For me the error emerges with all versions >= 1.0.0-rc1 of dragonfly.
Thank you for reporting this! I'm able to reproduce the issue.