dictation-toolbox / dragonfly

Speech recognition framework allowing powerful Python-based scripting and extension of Dragon NaturallySpeaking (DNS), Windows Speech Recognition (WSR), Kaldi and CMU Pocket Sphinx
GNU Lesser General Public License v3.0
383 stars 75 forks source link

Use of Natlink's window-specific rule activation feature #370

Closed drmfinlay closed 2 years ago

drmfinlay commented 2 years ago

I have been requested to use this Natlink/DNS feature in Dragonfly. It may be used to mark grammar rules as high priority, meaning that they override global DNS rules, or commands.

I have had some trouble getting this to work reliably. But, even if that were not the case, enabling this by default would deviate from behaviour that users have come to expect. So it will be added as off-by-default.

Since this is a Natlink-only feature, it will be enabled via the Natlink engine class:

# Define a Dragonfly grammar.
grammar = Grammar("My grammar")

# ... (add rules) ...

# Load the grammar.
grammar.load()

# Set each rule as high-priority.
engine = grammar.engine
assert engine.name == "natlink"
for rule in grammar.rules:
    engine.set_high_priority_rule(grammar, rule, True)

I'll add a less fiddly example, under dragonfly\examples, demonstrating use of this feature.

LexiconCode commented 2 years ago

This is great! I'll try to test this soon. In terms of reliability, can you expand on that some?

drmfinlay commented 2 years ago

I haven't got this working yet, actually. I just realised there wasn't a GitHub issue for it. It is partly implemented on the master branch. I will finish it there soon.

As to reliability, I think my code calls some Natlink functions in a way that causes problems. Vocola uses this feature by default and, though it has been a while, I don't remember having trouble.

drmfinlay commented 2 years ago

This feature is now implemented, and currently enabled by default, on the master branch version. Or, at least I think it is...

I'll be honest, I cannot discern any difference between normal and "high-priority" rules. My information is from Mark Lillibridge, who wrote about this in the Dragonfly Gitter channel in June/July.

Perhaps this only makes a difference on other versions of DNS? I'm on DNS 15. Let me know if you notice a difference, @LexiconCode.

drmfinlay commented 2 years ago

I haven't run into any problems with this, so it will be on by default in the next version. If users report problems related to this, I'll consider adding an option.