dictation-toolbox / Caster

Dragonfly-Based Voice Programming and Accessibility Toolkit
https://dictation-toolbox.github.io/Caster/
Other
340 stars 121 forks source link

Enabling text manipulation causes Caster to freeze on Kaldi #824

Closed jdcai closed 4 years ago

jdcai commented 4 years ago

Describe the bug I run the current master branch of Caster using Kaldi. When I say "Enable text manipulation" it causes Caster to freeze and I see 50%+ cpu usage in task manager. Text manipulation works on WSR.

To Reproduce Steps to reproduce the behavior (be sure to include the exact command phrase you are using): Run "Run_Caster_Kaldi.bat" After it finishes loading say "Enable text manipulation" You will see The rule TextManipulation was set to active. Caster stops listening to commands and Windows Command prompt is using 50% cpu. image

If I close and reopen it the same thing happens. I need to go into rules.toml and remove TextManipulation to get it working again. System:

LexiconCode commented 4 years ago

@jdcai thanks for the info!

This issue is being tracked as well in https://github.com/daanzu/kaldi-active-grammar/issues/22, but it's good have here in case others run into the bug.

LexiconCode commented 4 years ago

Okay there is a fix for text manipulation and kaldi freezing. Until it's officially published it can be installed with following. pip install git+https://github.com/daanzu/dragonfly.git#egg=dragonfly2[kaldi] --upgrade

LexiconCode commented 4 years ago

Officially included in dragonfly pip install --upgrade dragonfly2[kaldi]

Notes on how this bug occurred from daanzu.

For future reference: the problem seemed to require a confluence of factors, and it only occurred with all of them together:

* multiple, nested `Repetition`s (the outer for CCR/etc, and the inner for the character sequence)

* the same words being used in both the inner and outer Repetitions (in parallel)

* `optimize=True` in both the inner and outer Repetitions (especially the inner, where it is less important)

It is possible this still may happen again with even more complex grammars, where my fix can't simplify them enough, in which case setting optimize=False in the inner Repetition is probably the best course.

Repetition(character_choice_object, min=1, max=3, name="character_sequence", optimize=False)