KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: Squelching: Automatically ignore dictation in certain windows (at certain times)
Topic Summary: Preventing unmodified key shortcuts that go crazy if you dictate by accident
Created On: 06/23/2020 02:03 AM
Status: Post and Reply
Linear : Threading : Single : Branch
Keyword
 06/23/2020 02:03 AM
User is offline View Users Profile Print this message

Author Icon
Ag
Top-Tier Member

Posts: 1150
Joined: 07/08/2019

Originally I called this: Automatically switch to command mode in certain windows. Later, I changed the name to: Automatically ignore dictation in certain windows. Now, still later, I am adding "at certain times" to the title.

 

Of course, what I really want is in certain fields of certain windows accept dictation, while in others windows accept/reject dictation wholescale.  All for the same app.

 

LATER (5/25/2023): I now call this "Dictation Squelching".

 

 

 

Since my  BKM  doesn't switch to command mode,  but ignores all unmodified  letters.

 

The problem I was solving is that if you accidentally dictate into a window like Thunderbird that uses unmodified single  letter key shortcuts, things go badly. So  I want to disable such dictation by default, automatically, without having to say  "Switch to Command Mode" - I.e. before I have accidentally deleted or misfiled email.

 

I would prefer to automatically switch to command mode, because my AHK hack  is unnatural,  and poses challenges for command writing.   But it's all I have so far.

 

LATER:  I implemented automatically switching to command mode, and it turned out to be quite unpleasant.  Many things that you might say by accident will get mapped to commands of completely different names in command mode, whereas when you are just squelching dictation they are ignored.   Squelching dictation is better.

 

 

---

 

For various reasons I use Thunderbird email. Not speech ready.  

 LATER:  similar problems with many different programs, not just Thunderbird. See below

 

I have commands to emit the appropriate keyboard control sequences.  That's okay.

 

However, Thunderbird has quiter a few single key, unmodified, keyboard shortcuts. Like 

A archive

R mark thread as read

M mark message as read

K mark as junk

S toggle star

 

If I am in normal mode, and I utter something that Dragon interprets as dictation, Dragon sends the letters - and if one of the letters is as above, it's easy to have email accidentally arcvhived, marlerd as junk, etc.   I.e. it os easy to lose email messages this way - not necessarily delete them, but if they are removed from my Inbox or other folder without my noticing, not good.

 

Q: is there any way to prevent Dragon from inserting dictaion?  AUTOMATICALLY?

 

Sure, I know about the Force Command/Dictayion hotkeys, Ctrl/Shift.

 

First, these seem to interfere with SendKeys emitted by by Dragon/KmnowBrainer commands.  E.g. if I have Ctrl pressed to force Commands, then every SendKeys in my commands will have the Ctrl modifier.  (Or at least that seems to be the case - am I doing something wrong?)

 

Second, I don't want to have to remember to hit Ctrl to Force Commands. Especially since I am not at a keyboard most of the time.  Or to do "Start Command Mode".  I want this to be done automatically, whenever I enter or activate the Thunderbird reading window "*- Mozilla Thunderbird".  (But not in the writing window.)

 

I can write AutoHotKey to detect WinActivate... and theoretically then turn Command Mode On (and off on exit).  Here I'm just lazy - I haven't been able to get AHK to control the DragonBar well enough to change "Now listening for...".  

 

I can actually arrange for AHK to intercept all unmodified keys typed in the Thunderbird main window, silencing them.  Can't distinguish those from Dragon dictation and those from keyboard, but I can use heuristics.  (Wait, the actual event stream indicates the HID, doesn't it?  AHK_HID...)  Then after that, muist arrange to either not do this when a Dragon/KnowBrainer command is sendkeying...  or else have the speech command invoke an AHK script via ShellExecute to do the actual work.

 

--

 

Basically, as usual, I am lazy, and I hope that somebody else has already done something like this.  

 

Just asking...

 

And if not already done, I welcome suggestions as to better ways.

 

===

 

Although Thunderbird is the app that I have run into this today, this issue may arise on any app that has non-modified single key shirtcuts.

 

 

 

 



-------------------------

DPG15.6 (also DPI 15.3) + KB, Sennheiser MB Pro 1 UC ML, BTD 800 dongle, Windows 10 Pro, MS Surface Book 3, Intel Core i7-1065G7 CPU @ 1.3/1.5GHz (4 cores, 8 logical, GPU=NVIDIA Quadro RTX 3000 with Max-Q Design.



 06/23/2020 06:31 PM
User is offline View Users Profile Print this message

Author Icon
Ag
Top-Tier Member

Posts: 1150
Joined: 07/08/2019

Simple AHK

a::
...
z::

Accomplishes disabling all unmodified keys, thereby disabling all of the annoying Thunderbird single key shortcuts (well, need to disable any numbers and symbols, too).

unfortunately, it disables too much, because some unmodified keys need to be emitted in commands.

---

In  Force lowercase mode? I use a similar script, which accomplishes global Lowercase mode for Thunderbird.  unfortunately not for OneNote. At least not yet :-(

 



-------------------------

DPG15.6 (also DPI 15.3) + KB, Sennheiser MB Pro 1 UC ML, BTD 800 dongle, Windows 10 Pro, MS Surface Book 3, Intel Core i7-1065G7 CPU @ 1.3/1.5GHz (4 cores, 8 logical, GPU=NVIDIA Quadro RTX 3000 with Max-Q Design.



 06/25/2020 03:07 AM
User is offline View Users Profile Print this message

Author Icon
Ag
Top-Tier Member

Posts: 1150
Joined: 07/08/2019

After using this for a day, I am pretty happy. I have merged the kill_letters and the force_lowercase functionality into a single AHK script, mainly so that I can bind it all to CAPS_LOCK (w/wo modifiers). Of course, "press caps lock", etc., control things from speech, along with speech commands like "kill letters on/off" and "lowercase on/off". But the main point is that I don't normally need to change the things, the default is that kill_letters is on, and only effective in the main Thunderbird window.



So far I have mainly had to switch several of my commands like "... archive" to use keybd_event to hold down ALT while navigating the menus.

This will fall down when I need to have the commands enter letters, but those mostly live only in the message composition window. For searches I have to turn kill letters on/off, but I usually use Gmail search. Eventually I will need search commands that turn kill off as needed, without requiring separate commands.

Early days, but I think I am much less frustrated with Thunderbird+speech right now. I don't think I've had accidental dictation pop up crazy menus and throw email around as I was having before I disabled unmodified letter keys. Enough so that I just removed the confirmation step in my archive command, It works more reliably.

This technique will help any system that has a single key unmodified letter shortcuts. IIRC gmail, chrome, firefox. Although those usually have better ways of disabling keyboard shortcuts than Thunderbird currently does (the latest versions of Thunderbird broke most addons). Still, it's nice to have something that will work anywhere.





-------------------------

DPG15.6 (also DPI 15.3) + KB, Sennheiser MB Pro 1 UC ML, BTD 800 dongle, Windows 10 Pro, MS Surface Book 3, Intel Core i7-1065G7 CPU @ 1.3/1.5GHz (4 cores, 8 logical, GPU=NVIDIA Quadro RTX 3000 with Max-Q Design.

 06/25/2020 08:42 AM
User is offline View Users Profile Print this message

Author Icon
Mav
Top-Tier Member

Posts: 723
Joined: 10/02/2008

Take a look at your nsuser.ini file located at %appdata%\Nuance\NaturallySpeaking15.

 

You can tell Dragon to activate/deactivate dictation support in certain applications by adding a section [executableName|executableVersion\Compatibility Module Status]

 

In this section you add

 

Edit Control Support=0
Global Dictation=0

 

now Dragon should stop writing into this application.

I've tried with Notepad and it worked:

[notepad|10.0\Compatibility Module Status}
Global Dictation=0
Edit Control Support=0

 

As a side note: Dragon seems to monitor nsuser.ini for changes, so no need to restart Dragon after each modification. Just select a different window to apply your changes.

 

hth,

mav

 06/25/2020 10:04 PM
User is offline View Users Profile Print this message

Author Icon
Ag
Top-Tier Member

Posts: 1150
Joined: 07/08/2019

It looks like nsuser.ini disables dictation

 

a) on a per-app basis, not differently per window of the same app

 

b) statically

 

It turns out that in Thunderbird I need to dictate in the main window, in places like the search box.   But not in otheer places of the same main window.  Panes.  (What a pain main  panes are!! :-)

 

I will change the topic to "at certain times".

 



-------------------------

DPG15.6 (also DPI 15.3) + KB, Sennheiser MB Pro 1 UC ML, BTD 800 dongle, Windows 10 Pro, MS Surface Book 3, Intel Core i7-1065G7 CPU @ 1.3/1.5GHz (4 cores, 8 logical, GPU=NVIDIA Quadro RTX 3000 with Max-Q Design.

 06/26/2020 04:04 AM
User is offline View Users Profile Print this message

Author Icon
Mav
Top-Tier Member

Posts: 723
Joined: 10/02/2008

Yes, nsuser.ini only works on application basis, not single windows within an application.

Sorry, didn't understand your requirement good enough.

mav

 06/25/2020 10:47 AM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4615
Joined: 12/08/2007

Does Thunderbird provide an option to disable those keyboard shortcuts?

I'm not 100% sure, but I think there is an webmail program that offers users different sets of keyboard shortcuts. If Thunderbird is one of those, is there an option for a set of hotkeys that always use modifiers?

Or is there an option to to toggle off the keyboard shortcuts? As someone who needs to avoid using a mouse, I find single-character shortcuts get in my way, as they are too easy to activate by accident. When a shortcut is activated, it's a problem if the action performed happens with inadequate or no visual feedback. I turn off single key shortcuts whenever I can.

When keyboard interaction with web applications is poorly implemented or absent, I use macro software (Macro Express and/or AutoHotkey) to develop "virtually keyboard interfaces."

But developing a RELIABLE virtual keyboard interface is a challenging scripting project. I find these projects are simpler with Macro Express or AutoHotkey than with Dragon Advanced Scripting.

Once the set of custom keyboard commands work reliably, it's straightforward to voice-enable them. For example, if Alt + S is my keyboard shortcut to navigate to the "Sent" messages folder, then my "Go to Sent" Dragon command might be this:

SendDragonKeys "{Alt+s}"
 06/25/2020 02:40 PM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 1137
Joined: 11/05/2015

Hi Alan, if I understand you correctly, you proceed as follows:

1) Define a VKI "virtual keyboard interface" as a set of keybindings and actions.

2) Implement the VKI using MacroExpress, or AHK, or a combination of them.

3) When things settle down, define voice Dragon or KB scripts to fire the keystrokes.

 

When you say that defining a reasonable VKI is a challenging scripting project, what exactly do you mean? Are you referring to the VKI specification or to ME, AHK, or Dragon/KB? Thank you.



-------------------------

Win10/11/x64, AMD Ryzen 7 3700X/3950X, 64/128GB RAM, Dragon 15.3, SP 7 Standard, SpeechStart, Office 365, KB 2017, Dragon Capture, Samson Meteor USB Desk Mic, Amazon YUWAKAYI headset, Klim and JUKSTG earbuds with microphones, excellent Sareville Wireless Mono Headset, 3 BenQ 2560x1440 monitors, Microsoft Sculpt Keyboard and Logitech G502 awesome gaming mouse.



 06/25/2020 09:56 PM
User is offline View Users Profile Print this message

Author Icon
Ag
Top-Tier Member

Posts: 1150
Joined: 07/08/2019

There are  several  Thunderbird packages to  configure keyboard shortcuts, but all of them as far as I know stopped working completely reworked its add-on  architecture.  

 

E.g. Dorando keyconfig stopped working at Thunderbird 5.0b1 - 60.*, and Thunderbird is now at v68.  Although to 60.*->68 transition was only circa Oct 2019.

 

 Although I would probably have just disabled Thunderbird single  key shortcuts if the package was available, there are some advantages to having this reality. E.g. I can use it for similar shorcut situations in other apps.   I may still go back to the earlier versions of Thuunderbird. I did not switch; I had not used Thunderbird in years before I returned to it circa March.

 

 



-------------------------

DPG15.6 (also DPI 15.3) + KB, Sennheiser MB Pro 1 UC ML, BTD 800 dongle, Windows 10 Pro, MS Surface Book 3, Intel Core i7-1065G7 CPU @ 1.3/1.5GHz (4 cores, 8 logical, GPU=NVIDIA Quadro RTX 3000 with Max-Q Design.

 06/25/2020 03:23 PM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4615
Joined: 12/08/2007


When you say that defining a reasonable VKI is a challenging scripting project, what exactly do you mean? Are you referring to the VKI specification or to ME, AHK, or Dragon/KB?


I mean these projects usually take time and effort. How much time and effort? That depends mostly on the web application, sometimes on the browser, and occasionally on the operating system. Whether I use Macro Express or AutoHotkey is a comparatively minor issue. Both have their advantages and disadvantages.

Typically, it doesn't take long to develop a handful of macros. But refining the macros so they work reliably tends to consume much more time.
 06/25/2020 05:12 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2272
Joined: 03/21/2007

Just thought of this.

 

How about a command called "switch to thunderbird" that switches to thunderbird (appbringup, heardword, whatever) and then switches to command mode right away?

EngineControl.RecognitionMode = dgnrecmodeCommand

 

Your "new email" command could include switching back to normal mode to allow the message composition:

EngineControl.RecognitionMode = dgnrecmodeNormal

 

And then your "send email" or "move to draft" commands could do the switching to command mode to put you back. You get the idea, I guess?

Would that help?



-------------------------




PG





Remember folks, my comments and this forum are for entertainment value only, please, no wagering or other reliance on the contents herein.  I permit no commercial use of my ideas (whether expressions or embodiments) without my written consent.



 06/25/2020 10:07 PM
User is offline View Users Profile Print this message

Author Icon
Ag
Top-Tier Member

Posts: 1150
Joined: 07/08/2019

Helps, yes, I already had that.

 

But there's a difference between putting it in a command, and having it done automatically based on context.  



-------------------------

DPG15.6 (also DPI 15.3) + KB, Sennheiser MB Pro 1 UC ML, BTD 800 dongle, Windows 10 Pro, MS Surface Book 3, Intel Core i7-1065G7 CPU @ 1.3/1.5GHz (4 cores, 8 logical, GPU=NVIDIA Quadro RTX 3000 with Max-Q Design.

 05/26/2023 01:16 AM
User is offline View Users Profile Print this message

Author Icon
Ag
Top-Tier Member

Posts: 1150
Joined: 07/08/2019

WIP status update: I have been working on/using this quite a lot recently, and I intend to write a longer descriptive post. But for now, briefly ...


I now call this "Dictation Squelching", since automatically changing between normal and command recognition modes is not necessarily the best way to do this.


my AHK code has been hooking RegisterShellHookWindow/RegisterWindowMessage/SHELLHOOK


Originally I was looking for window activations and changing the recognition mode. at 1st using RecognitionMimic, but that has obvious problems with race conditions as to which window is open. Later using the Dragon recognition engine DllCalls.


The recognition mode approach has become moot, because it quickly became obvious that I get worse recognition when I am in Command Mode and when I'm in Normal Mode. Although surprising at 1st, it can be understood upon reflection: when in Command Mode pretty much any utterance is mapped to a command. Even if it really should not be. Whereas in Normal Mode some utterances are mapped to commands and some to dictation. E.g. if your wife comes into the room and you start talking to her without turning the microphone off, in command mode everything is a command. Whereas in normal mode, if you can actually squelch the dictation, whatever you are saying to your wife will not be interpreted as a command. Of course, the problem that started the search all off is "how do you squelch the dictation", because if the ordinary printable characters of your dictation are each interpreted as hotkeys, then ... well, actually, I quickly figured out that I preferred having CmDiK errors to the sort of CmC errors that you get in command mode.


Specifically, I clearly remember when a whole slew of commands one after the other got misrecognized as DragonCapture AutoPaste. Flipping the DragonCapture AutoPaste feature on and off. And these commands really Really REALLY did not sound like "AutoPaste". Perhaps "DRACO Paste" sounds a bit like "AutoPaste", but some of the others were really different.


anyway, I was thrashing around with CmC errors, commands misrecognized as other commands in Command Mode, turning DragonCapture AutoPaste on-and-off when I realized...


... I realized that the problem was not switching between Dragon command and normal recognition modes


but that I really wanted to be in normal mode, and just have the dictation ignored. squelched, if you will


and that DragonCapture already did this: If AutoPaste is off, dictation accumulates in the DragonBox. I can just leave the dictation in the DragonBox and never insert it into the application.


In fact, there is the rather pleasant side effect of a CmD error - command misrecognizes dictation - being stored in the DragonCapture box, so that I can see what was misrecognized. this is much like the Dragon recognition history, but a little bit more convenient, because you can easily go in and edit it. People who know me will not be surprised to find out that I am trying to record misrecognitions, keep statistics, and thereby improve my command set design.


I believe that the same thing can be done with the standard Dragon dictation box, and probably with something like speech productivities dictation boxes.


However, hooking onto the window activation messages doesn't work so well when I am controlling DragonCapture, since AFAIK DragonCapture does not have any programmatic API. My choices seem to be to control it by emulating mouse and keyboard, or by RecognitionMimic. At the moment I am using RecognitionMimic.


I've been finding that it works almost as well to have AutoHotKey bindings for the left button click that usually selects a window turn DragonCapture AutoPaste on and off. It just seems to work more reliably than the window activation messages. Of course, hooking the left mouse click button does not help you when there are other ways of activating Windows, like the Alt-Tab switcher etc. So I still have the window activation message can code around.


Issues with the window activation hooking: Race conditions? With timestamped tracing I have observed cases where the hook is invoked before the window is open, and after ... in fact for very brief windows, invoked after the window has been opened and then closed. Handling all of those edge cases is a bit of pain. similar conditions can arise when hooking on to something like theft button click and then invoking DragonCapture AutoPaste via RecognitionMimic, but they don't seem to bite me as often. Like at all.   ...  Oh, yeah: another issue with the window message hooking: if a hok takes too long it gets disabled.




Anyway, that's where I am: Dictation Squelching using DragonCapture AutoPaste attached to left button clicking via AutoHotKey (and a few other places). I'm getting reasonably happy with it.


Of course, the standard dictation boxes like DragonCapture are really not what I should be using here. In an ideal world I would have something that intercepted the dictation stream in much the same way that DragonCapture or the standard dictation box does, but which did things that a dictation box wouldn't really want to do: obviously, the sort of Dictation Squelching that I'm doing now, but probably also other things like ** lowercase lock (to dragon's really annoying pseudorandom capitalization which is really an appropriate for programming); ** better recognition history; ** and a number of things like vortex++


but for the moment, my code that uses DragonCapture AutoPaste as a DIY dictation squelching mechanism works well enough

 

---

 

And in case anyone cares:    I am doing things like turning off dictation squelching when I'm in the search box of the eMclient window, but turning it on elsewhere in that same window. Same window, same window title, same control ...   in other words no way for Dragon to distinguish the search box context where I want dictation from the message list where I do not.  At the moment I am using  the XY coordinates of the text cursor/caret.   it looks like I will be able to use UIA to make a slightly better distinction.



-------------------------

DPG15.6 (also DPI 15.3) + KB, Sennheiser MB Pro 1 UC ML, BTD 800 dongle, Windows 10 Pro, MS Surface Book 3, Intel Core i7-1065G7 CPU @ 1.3/1.5GHz (4 cores, 8 logical, GPU=NVIDIA Quadro RTX 3000 with Max-Q Design.



 08/21/2023 10:34 PM
User is offline View Users Profile Print this message

Author Icon
Ag
Top-Tier Member

Posts: 1150
Joined: 07/08/2019

STATUS REPORT: I remain reasonably happy with the version of dictation squelching that

a) Squelches dictation by turningDragonCapture AutoPaste on/off
a.1) using AutoHotKey Control,Check/Uncheck
a.2) Although it was unfortunately necessary to save/restore the currently active window

b) automatically invoked on mouse left clicks

c) automatically invoked at OnExit of my AutoHotKey based speech commands


shortcomings:

* I would really prefer this to be 100% automatic, e.g. when a dialog box is opened by physically typing AQI, or by saying "press key" or the like.

* I did hook such focus change events, but they seemed to interfere with scripts that were themselves opening and closing windows and dialogs

* e.g. it is unfortunate that AutoHotKey control cchecck/uncheck changes window focus

* also, I was only able to hook changes between application window focus, and I did not intercept ffocus changes within an application, like opening or closing DialogBox.
** however, I'm pretty sure I know how to do that, it just doesn't seem worthwhile because of the interference issue

it might be possible to avoid the interference issue by recording the need to determine if squelching is necessary, but not performing it immediately, instead waiting until there is some sort of quiescence in which no commands are pending.

-------------------------

DPG15.6 (also DPI 15.3) + KB, Sennheiser MB Pro 1 UC ML, BTD 800 dongle, Windows 10 Pro, MS Surface Book 3, Intel Core i7-1065G7 CPU @ 1.3/1.5GHz (4 cores, 8 logical, GPU=NVIDIA Quadro RTX 3000 with Max-Q Design.

Statistics
32617 users are registered to the KnowBrainer Speech Recognition forum.
There are currently 1 users logged in.
The most users ever online was 12124 on 09/09/2020 at 04:59 AM.
There are currently 102 guests browsing this forum, which makes a total of 103 users using this forum.

FuseTalk Standard Edition v4.0 - © 1999-2023 FuseTalk™ Inc. All rights reserved.