dictation-toolbox / Caster

Dragonfly-Based Voice Programming and Accessibility Toolkit
Other
337 stars 121 forks source link

grammar precedence doesn't seem to work correctly on Kaldi #812

Open kendonB opened 4 years ago

kendonB commented 4 years ago

Describe the bug Two bugs I believe caused by the same thing.

  1. Trying to cancel a mouse grid does not work when using Kaldi
  2. Using squat and bench do not work when using Douglas on Kaldi

To Reproduce Steps to reproduce the behavior (be sure to include the exact command phrase you are using):

  1. Run Caster with Kaldi
  2. Say 'Douglas'
  3. Say '8 by 4'
  4. Say 'squat'

Caster runs the Navigation squat command not the Douglas one.

Expected behavior Douglas records that you have squatted.

Comments If I recall correctly, Caster doesn't currently have a formal process for dealing with conflicts between rules. However, when using Dragon Naturallyspeaking, these sorts of "knockout" behaviours just seemed to work correctly. As in, Dragon/Natlink/Caster correctly knew to use the mouse grammar and not the navigation grammar. Any help from @synkarius would be very welcome!

System:

LexiconCode commented 4 years ago

Good catch. The behavior working correctly with DNS is related to something within Natlink.

daanzu commented 4 years ago

Yeah, different engines handle ambiguous grammars differently. The current recommended way to handle this in Kaldi is to set a weight on one of them, to determine which should take precedence. Technically, "priority" and "weight" are slightly different concepts, but in the interest of simplicity, I think weight suffices. Any weight set will be simply ignored by engines that don't support it.

kendonB commented 4 years ago

I also just noticed that this is actually not consistent. So i guess there is some amount of randomness as well? It also rarely will choose the Legion one but not never.

kendonB commented 4 years ago

Awesome. Just added weight=1000 and it just seems to work perfectly! Thanks @daanzu

daanzu commented 4 years ago

FWIW, I usually just add a weight=10 to my "special mode" grammars, but I haven't done much testing of it.

LexiconCode commented 4 years ago

Awesome. Just added weight=1000 and it just seems to work perfectly!

As you find other issues like this don't hesitate to open up a pull request as setting weights shouldn't affect other engines.