dictation-toolbox / Caster

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

Implemented microphone modes #853

Closed LexiconCode closed 3 years ago

LexiconCode commented 3 years ago

Description

Implemented microphone modes to toggle microphone on, off, and sleep.

The new commands caster <mode> on, sleep, off (DNS/DPI only)

These modes use grammar/rule exclusivity to block other grammars from being recognized.

These modes are implemented through 2 rules. The 1st rule CasterMicRule to execute the function to enable exclusivity. The 2nd rule sleep_rule leverages native dragonfly to become exclusive via ExclusiveManager overriding CasterMicRule and all other rules loaded into the engine. sleep_rule uses dragonfly FuncContext to toggle on and off. Both rules use EngineModesManager to manage the different modes based on the engine is running. There are some significant differences. DNS utilizes Natlink and _sync_mode to synchronize modes then uses ExclusiveManager. The other engines utilize just ExclusiveManager.

Note because native dragonfly was used for sleep_rule simplified transformers cannot be used on CasterMicRule or sleep_rule.

Could this implementation be simplified? If we could create separate CCR merger that's for exclusive grammars only it would drastically simplify the implementation.

What about additional modes? These are some thoughts for the future but not in this PR. I did not want to take longer to get the sleep mode out to users as it impacts the usability of Caster.

Related Issue

https://github.com/dictation-toolbox/Caster/issues/797

Motivation and Context

Motivation for this is to unify microphone modes command regardless of the speech recognition backend for users.

How Has This Been Tested

I've tested this with DNS and Kaldi switching between microphone modes.

Types of changes

Checklist

Maintainer/Reviewer Checklist

esc123 commented 3 years ago

Using DPI 15.3 on Windows 10, all three commands (on, off, sleep) work perfectly. Good stuff.

kendonB commented 3 years ago

@LexiconCode is there an easy way to implement automatic sleeping functionality? I often forget that the system is on after using it for a few minutes and end up making it do a bunch of crazy things because I'm speaking around it or listening to something.

LexiconCode commented 3 years ago

@LexiconCode is there an easy way to implement automatic sleeping functionality? I often forget that the system is on after using it for a few minutes and end up making it do a bunch of crazy things because I'm speaking around it or listening to something.

Yes I think that shouldn't be too bad to do. It would involve creating a timer that is reset every time there's a successful recognition.