KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible
Topic Summary: KBCOMMAND <dictation> ==> external script (e.g. AHK)
Created On: 09/13/2020 09:41 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - Ag - 09/13/2020 09:41 PM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - Lunis Orcutt - 09/14/2020 01:29 AM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - Edgar - 09/14/2020 11:53 AM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - kkkwj - 09/14/2020 05:28 PM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - Edgar - 09/14/2020 08:41 PM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - Ag - 09/14/2020 06:55 PM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - Edgar - 09/14/2020 08:46 PM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - Ag - 09/14/2020 07:04 PM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - Edgar - 09/14/2020 08:49 PM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - Ag - 09/15/2020 04:25 PM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - Lunis Orcutt - 09/15/2020 09:55 PM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - kkkwj - 09/16/2020 12:02 AM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - Ag - 09/21/2020 11:57 PM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - Lunis Orcutt - 09/22/2020 12:59 AM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - Ag - 09/22/2020 10:38 AM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - Lunis Orcutt - 09/22/2020 07:08 PM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - R. Wilke - 09/22/2020 11:40 AM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - Ag - 09/25/2020 05:07 PM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - Edgar - 09/23/2020 12:03 PM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - PG LTU - 09/23/2020 01:18 PM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - Edgar - 09/23/2020 03:36 PM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - PG LTU - 09/23/2020 04:11 PM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - Edgar - 09/23/2020 05:15 PM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - Edgar - 09/23/2020 04:26 PM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - PG LTU - 09/23/2020 05:17 PM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - PG LTU - 09/23/2020 05:24 PM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - Ag - 09/25/2020 05:13 PM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - kkkwj - 09/25/2020 09:30 PM  
 BKM for KnowBrainer coding - do as little in KnowBrainer (Command Editor) as possible   - Edgar - 09/26/2020 11:59 AM  
Keyword
 09/13/2020 09:41 PM
User is offline View Users Profile Print this message

Author Icon
Ag
Top-Tier Member

Posts: 449
Joined: 07/08/2019

BRIEF:

 

This weekend I wrote quite a few nice operations for KnowBrainer, by writing a single KnowBrainer command "PUFF Window ", ShellExecute'ing a single AutoHotKey script which did all the work, including the command parsing.

 

 

BACKGROUND:

 

My main motivation for doing this was KnowBrainer slowness when editing in the "KnowBrainer Command Editor".  Every time I try to execute a command after saving it (or any other KnowBrainer command), I get stalls of nearly always 1-2 minutes, frequently much longer.  Worse, commands pile up,  and get released all at once. 

 

Note:  I nearly always use KnowBrainer  to edit my commands. Mainly because when I (re)started using Dragon in the middle of 2019, Dragon's command editing tools were really, Really, REALLY bad on my system with  heterogenous displays -  multiple displays (currently  four),  different shapes, different display scaling.   Frequently the Dragon command editing windows were unreadable. Checking right now this seems to have improved, although when I went DragonBar > ? > "About Dragon" Find the version number, the Window thrown up was unreadably small, and could not be moved to a display with bigger pixels  and less display scaling,  enough so that I needed to take a screenshot to blow it up  (could probably use a screen magnifier, but I know the screenshot keyboard shortcuts by heart).  The KnowBrainer sidebar and the command editor are not perfect  with regard to display scaling,  but they seemed better than Dragon's native stuff when I started.

 

I already knew that the way to share code Between KnowBrainer commands was to use '#Uses, and I had already learned that editing in the included text file was much faster than editing in the KnowBrainer Command Editor. 

 

However,  it was still necessary to use the KnowBrainer Command Editor when creating a command, and when modifying its arguments,  e.g. when creating lists.  Since I create a lot of small commands, and do a lot of small edits, incremental coding and testing, that was creating a lot of friction and fustration. Also a few crashes.

 

So at the start of this weekend I wrote a generic command "PUFF Window " that ShellExecute'd that passed its argument to a generic  AutoHotKey script.

 

Hallelujah!!  Much faster edit cycles.

 

I do not know what KnowBrainer is doing every time I edit a command, but it is low.  I conjecture it is  manipulating the  MyKBCommands.xml file,  but  that should not take too long. I thought that KnowBrainer might be compiling the command, but Lunis assures us that is not the case (as evidenced by '#Uses being fast).  I suspect that it is an interaction between Dragon and KnowBrainer, e.g. loading the patterns/grammars, including lists.  Whatever the cause, it is unreasonably slow. ShellExecute'ing an AHK script  leads to much faster edit cycles.

 

I am not 100% sure, but I also think that  this coding workflow ShellExecute'ing the AHK script is more stable.  Less evidence of the really long stalls in Dragon/KnowBrainer that get longer and longer, exceeding five minutes,  which eventually require restarting (unfortunately Restart Dragon often doesn't work),  and often seem to require creating a new profile.

 

Unexpected benefit: I can do more efficient  argument parsing using  regular expressions in AHK than in aKnowBrainer/Dragon basic.  Many commands written in  the standard basic dialects have gret big chunks of code of the form 

 

  • if ListVar1 = "1" then SendKeys "[01]"
  • ...
  • if ListVar1 = "99" then SendKeys "[99]"

 

whereas in a real programming language[*] like  AutoHotKey or Perl or Python I create an associative array  and then do a single SendKeys:

 

  • %map_arg_to_value = ( ... )
  • SendKeys sprintf("[%02d]",$map_arg_to_value{$ListVar1}) 

 

*: I'm baiting you Basic people to show you equivalent idiom.

BTW, note that in the if ListVar1 cascade, every comparison is done, whereas only one should match.  Unecessary work. I might hope that the Basic system optimizes that to code similar to the hash/associative array.  (Yes, I realize that you need to amortize  the cost of building the hash table over multiple uses of the same command;  if it is rebuilt from scratch each time it is probably not a win.)

 

 Furthermore, elsewhere in this forum folks have reported that having extremely long lists in command arguments, like <1to500>,  leads to Dragon slowness

Alan Cantor: Dragon slows when custom commands have too many variations. (I don't remember the exact number that have to be present before latency becomes noticeable.)

 

If any of your custom commands have thousands of variants, disable or simplify them. For example:

Test [1-100] [1-100] point [1-100]

has 1 million variants. Try this instead, which has only a thousand variants:

Test [1-10] [1-10] point [1-10]

 

Whereas if I just defined "Test "

and had AHK do

RegexMatch(arg,"^([0-9]{2})[0-9]{2}).([0-9]{2})$"...) and then range check the matches there is only a single variant.

 

Moreover, I can add more such argument parsing at any time, without having to go through the slow KnowBrainer Command Editor code/test loop.

 

Now there is shortcoming:  "Test X [1-100] Y [1-100] Z [1-100]"  gives the Dragon speech recognition engine  a grammar  that can disambiguate utterances, whereas passed to an external script does not,  even if the external script is doing more powerful parsing.  so far careful pronunciation has allowed me to use this  without  many problems.  Eventually I may write basic commands with lists/ grammars exposed to Dragon,  once the experimental phase of  designing and coding  a speech command set is over.

 

Another benefit:  having Dragon/KnowBrainer call an external script like AutoHotKey or Perl or Python (a)  allows me to use the very big libraries of code available for the scripting languages, and also allows my code to be used both for speech command sets  and for AHK  keyboard shortcuts and GUI menus systems.    I was expecting  this to be of great value, for the still unfortunately common for me situations where Dragon/KnowBrainer speech recognition and commands fail, and were even SpeechStart+ restart Dragon does not work.  however, calling the external script has also improved stability to the point where I haven't had to try to call Restart Dragon at all today.

 

--

 

This is probably obvious to any  programmer/hacker of even moderate skill. I wish that I had not wasted so much time learning the hard way to try to avoid the KnowBrainer Command Editor

 

As I have mentioned elsewhere, I hope someday to have the time to start evaluating the speech command systems  based on modern programming languages like Python, not Basic, like DragonFly.  I have been slow to do this because I have been wasting so much time wrestling with slowness is in Dragon and KnowBrainer, but also because of fear of getting stuck in a rathole, always looking to the next Python system.  Having to rewrite commands in Python that already exist in KnowBrainer. Possibly giving up on utilities like DragonCapture (I do not know if DragonCapture can interoperate with DragonFly).

 

Indeed, having KnowBrainer invoke external scripts might be a way of incrementally switching over.

 

---

 

 But in any case: this pattern, of having a stub KnowBrainer Command Editor pass to  external scripts  for fancy command parsing has made me much happier.

 

 



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

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.



 09/14/2020 01:29 AM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 37992
Joined: 10/01/2006

We are aware of the painful KnowBrainer sluggishness when creating or editing a command. This will be remedied when we prune about 75% of rarely used KnowBrainer commands that no one will likely miss. We will begin pruning after we finished the manuals. The 1st manual will be for Dragon and the 2nd manual will cover Pure KnowBrainer. Fortunately both manuals will be almost identical.


Now that DPI 15.6 has finally arrived, you will soon be able to use VB II directly in Dragon and enjoy the quick deployment and easy editing/construction. VB II is finished but you are waiting on the manual. We have finished the 1st of 2 chapters with a few videos. The only thing that remains is the scripting code list, definitions and how to use. We hope to have this ready in a couple of weeks or by the time we run out of Thunderbird. This version of VerbalBasic will include random-access and WYSWYS (What You See Is What You Say). You can edit or script from any random position. You can forget where the cursor is and we have just added Commenting (3 choices) and Lists (17 choices). You can say goodbye to those Dragon List menus too. Multi Line Scriping (up to 10) is available along with single utterance boilerplate text and mouse position commands. DPI 15.6 couldn't have better timing.



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

Forum Mission Statement
Trial Downloads
Dragon/Sales@KnowBrainer.com 
(615) 884-4558 ext 1



 09/14/2020 11:53 AM
User is online View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 915
Joined: 04/03/2009

I've also gotten out of the habit of using Dragon/KnowBrainer scripting but have not quite gotten to your your generic "one Dragon/KnowBrainer script to call them all" scenario - great idea! I've even started using C# instead of any of the Basic-based languages. I still use KnowBrainer if it's something trivial which I know will be deleted soon. I still use AutoIT3 if it's something complicated but only involves mouses is thing and key sending. Pretty much everything else I'm now doing with C#. I use ShellExecute or AppBringUp from a KnowBrainer script which means I only experience the KnowBrainer slowdown once; then I use MS Visual Studio 2017 to write/debug the command. The only problem is - there are a few things that Dragon knows how to do which I have not figured out how to do with an external application.

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

-Edgar
DPI 15.3, 64-bit Windows 10 Pro, OpenOffice & Office 365, Norton Security, Shure X2U XLR to USB mic adapter with Audio Technica DB135 vocal mic, Asus X299-Deluxe Prime, Intel Core i9-7940X (14 core, 4.3 GHz overclocked to 4.9 GHz), G.SKILL TridentZ Series 64GB (4 x 16GB) DDR4 3333 (PC4 26600) F4-3333C16Q-64GTZ, NVIDIA GIGABYTE GeForce GTX 1060 GV-N1060G1 GAMING-6GD REV 2.0 6GB graphics card with 3 1920x1080 monitors

 09/14/2020 05:28 PM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 497
Joined: 11/05/2015

Hi Edgar, may I ask why you're still on VStudio 2017 when 2019 Community is out? Does your 2017 version have more Professional features or something? Thanks

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

Win10/x64, AMD Ryzen 7 3700X, 64GB RAM, Dragon 15.3, SP 6 PRO, SpeechStart, Office 365, KB 2017, Dragon Capture, Samson Meteor USB Desk Mic, Klim and JUKSTG earbuds with microphones

 09/14/2020 08:41 PM
User is online View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 915
Joined: 04/03/2009

VS 2019 still has a lot of bugs (more than/different from 2017?). Also, there was something they removed (they keep removing stuff - 2017 has had stuff removed as compared to 2015 etc.) which was a dealbreaker for me using it hands-free - can't recall off the top of my head what it was! I suppose I should give it another try…



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

-Edgar
DPI 15.3, 64-bit Windows 10 Pro, OpenOffice & Office 365, Norton Security, Shure X2U XLR to USB mic adapter with Audio Technica DB135 vocal mic, Asus X299-Deluxe Prime, Intel Core i9-7940X (14 core, 4.3 GHz overclocked to 4.9 GHz), G.SKILL TridentZ Series 64GB (4 x 16GB) DDR4 3333 (PC4 26600) F4-3333C16Q-64GTZ, NVIDIA GIGABYTE GeForce GTX 1060 GV-N1060G1 GAMING-6GD REV 2.0 6GB graphics card with 3 1920x1080 monitors

 09/14/2020 06:55 PM
User is offline View Users Profile Print this message

Author Icon
Ag
Top-Tier Member

Posts: 449
Joined: 07/08/2019

Originally posted by: Edgar there are a few things that Dragon knows how to do which I have not figured out how to do with an external application.



Can we create a list of such things?


I don't disagree - but if we had a list we might be able to fill in the blanks as we randomly roam the net.



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

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.

 09/14/2020 08:46 PM
User is online View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 915
Joined: 04/03/2009

Originally posted by: Ag
Originally posted by: Edgar there are a few things that Dragon knows how to do which I have not figured out how to do with an external application.
Can we create a list of such things? I don't disagree - but if we had a list we might be able to fill in the blanks as we randomly roam the net.

1. (Easily) get the last utterance - the way I am doing it now is to open the recognition history dialog briefly and copy it from there.

2. ControlPick (which never worked well and probably doesn't work at all anymore - for things with no accelerator keys nor keyboard shortcuts).

3. MenuPick (ditto).

Look at this page of the Dragon documentation:

https://www.nuance.com/products/help/dragon/dragon-for-pc/scriptref/Content/scrptref/scripting_language_quickref.htm

 



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

-Edgar
DPI 15.3, 64-bit Windows 10 Pro, OpenOffice & Office 365, Norton Security, Shure X2U XLR to USB mic adapter with Audio Technica DB135 vocal mic, Asus X299-Deluxe Prime, Intel Core i9-7940X (14 core, 4.3 GHz overclocked to 4.9 GHz), G.SKILL TridentZ Series 64GB (4 x 16GB) DDR4 3333 (PC4 26600) F4-3333C16Q-64GTZ, NVIDIA GIGABYTE GeForce GTX 1060 GV-N1060G1 GAMING-6GD REV 2.0 6GB graphics card with 3 1920x1080 monitors



 09/14/2020 07:04 PM
User is offline View Users Profile Print this message

Author Icon
Ag
Top-Tier Member

Posts: 449
Joined: 07/08/2019

@Edgar, @kkkwj:

BTW, what is the current best/cheapest way to get MS developer tools? Which of the umpteen versions of Visual Studio or whatever. I no longer do most of my work on Windows, no longer have an MSDN subscription, and I got dizzy the last time I tried to figure out what version of Visual Studio to buy... I think there was also a free version.

BTW^2, how hard is it to bind C# to arbitrary key and mouse shortcuts? (Can't be all that hard.)

I very much like being able to share code between speech and key/mouse commands. For that matter, I would also like to be able to share code between
Microsoft Windows and UNIX X/Windows key/mouse commands. although that seems to rule out both AHK and C#, leaving mostly Python. Any other candidates?

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

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.

 09/14/2020 08:49 PM
User is online View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 915
Joined: 04/03/2009

Originally posted by: Ag @Edgar, @kkkwj: BTW, what is the current best/cheapest way to get MS developer tools?

There are "Community" versions of Microsoft Visual Studio available for free to anyone. Finding the 2019 version is easy looking for earlier versions can be a bit of a challenge! The "Community" versions typically lack a few of the more esoteric functions when compared to the big bucks versions (but the bugs are common to all).



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

-Edgar
DPI 15.3, 64-bit Windows 10 Pro, OpenOffice & Office 365, Norton Security, Shure X2U XLR to USB mic adapter with Audio Technica DB135 vocal mic, Asus X299-Deluxe Prime, Intel Core i9-7940X (14 core, 4.3 GHz overclocked to 4.9 GHz), G.SKILL TridentZ Series 64GB (4 x 16GB) DDR4 3333 (PC4 26600) F4-3333C16Q-64GTZ, NVIDIA GIGABYTE GeForce GTX 1060 GV-N1060G1 GAMING-6GD REV 2.0 6GB graphics card with 3 1920x1080 monitors

 09/15/2020 04:25 PM
User is offline View Users Profile Print this message

Author Icon
Ag
Top-Tier Member

Posts: 449
Joined: 07/08/2019

BTW, yesterday I added a command "PUFF " - as I often mention, I prefix nearly all of my KnowBrainer commands by "PUFF".

This has several benefits:

(1) I now get a nice error message "Unexpected command: PUFF foobar. Speech misrecognition error?"

(2) I can log such errors, so that I have data that can guide

(2a) training or adding custom words and phrases for misrecognized terms in commands. I have always been able to do this, but I haven't any automatically gathered stats for this.

(2b) When the speech was recognized correctly but the grammar was incorrect, I now have stats that can guide me in creating alternative grammars. For example, historically I have had a command "PUFF highlight orange faint", and I have long suspected that I should also have "PUFF hightlight faint orange" and "PUFF faint orange highlight". (This is a contrived example: I have always known that I should have such alternate word orders, but they were a bit of a pain to create until I started using external scripts. also, I tend to have a "big endian" just to make things easier to search for in KnowBrainer's sidebar. This is a contrived example - the point is that by automatically logging such errors I have more data to guide command set design.)


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

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.

 09/15/2020 09:55 PM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 37992
Joined: 10/01/2006

KnowBrainer definitely has a problem deploying new or edited global commands. Fortunately you only have to suffer this miserable delay once. We just pruned out about 50% of the commands and have uploaded a new download. New global commands took 31 seconds on our system. Unfortunately, 1st run KnowBrainer commands are still taking 15 seconds. 


We think we have a handle on why 1st run KnowBrainer commands are still taking 15 seconds. We suspect that we have bloated KnowBrainer with 2 sets of VerbalBasic commands; one for KnowBrainer and the other for Dragon. If this turns out to be the case, we may simply move the Dragon VerbalBasic commands directly into Dragon but that's still up in the air. If this turns out to be the issue, we should have a remedy within the next 2 weeks.


We have also come up with a temporary solution to prevent KnowBrainer from potentially causing Dragon to freeze. For the time being, please launch Dragon before launching KnowBrainer and you should be good to go.



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

Forum Mission Statement
Trial Downloads
Dragon/Sales@KnowBrainer.com 
(615) 884-4558 ext 1



 09/16/2020 12:02 AM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 497
Joined: 11/05/2015

Ag, I run VStudio 2019 Community Edition now (and have run VS since 2015?). I've only experienced one change recently in VS2019 that broke one of my ReSharper features, but ReSharper fixed it within a week or two.


I think you can program in C# with VSCode or VStudio for both Unix and Windows if you run Mono on *nix and build your C# code on the .NET Core platform (multiplatform) instead of on the .NET Framework (windows only). Visual Studio only runs on Windows, but VSCode is a much simpler IDE that is multiplatform (I'm thinking it might run in a browser or something).


>> BTW^2, how hard is it to bind C# to arbitrary key and mouse shortcuts? (Can't be all that hard.)

It isn't that "hard," but it requires a good learning curve (measured in days at least), collecting and parsing and representing the keybindings and mouse coordinates in code, and then making a pile of OS calls to get the job done (perhaps with wait/sleep commands between keystrokes). Add to that the VS projects overhead, calling your C# from Dragon, and so on. Lindsay always makes it look very simple when he posts little KB scripts to do it (I'm envious :-)); maybe you could try KB using his examples and save yourself some time.

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

Win10/x64, AMD Ryzen 7 3700X, 64GB RAM, Dragon 15.3, SP 6 PRO, SpeechStart, Office 365, KB 2017, Dragon Capture, Samson Meteor USB Desk Mic, Klim and JUKSTG earbuds with microphones

 09/21/2020 11:57 PM
User is offline View Users Profile Print this message

Author Icon
Ag
Top-Tier Member

Posts: 449
Joined: 07/08/2019

Originally posted by: Lunis Orcutt KnowBrainer definitely has a problem deploying new or edited global commands. Fortunately you only have to suffer this miserable delay once. We just pruned out about 50% of the commands and have uploaded a new download. New global commands took 31 seconds on our system. Unfortunately, 1st run KnowBrainer commands are still taking 15 seconds.


I *wish* I only had to suffer delays of 15-30 seconds. I just suffered such a stall of 3 minutes; I regularly suffer > 5 minutes.

Q: what do you mean, "you only have to suffer this miserable delay once?" I suffer it every time I edit a (global) command. Re-editing the same command. Editing different commands.



We suspect that we have bloated KnowBrainer with 2 sets of VerbalBasic commands; one for KnowBrainer and the other for Dragon. If this turns out to be the case, we may simply move the Dragon VerbalBasic commands directly into Dragon but that's still up in the air.


Q: do you provide an easy way of deleting the VerbalBasic commands? As far as I know I don't use Verbal Basic at all. I would like to get rid of anything that is slowing me down in the KnowBrainer edit-code-test cycle.

My global command "PUFF " helps a lot, since I am now mostly editing an AHK script called from this single global KnowBrainer script. But occasionaly I still have to edit KnowBrainer global commands - sometimes as part of refactoring to move their functionality out of KnowBrainer and into AHK. But also sometimes the other way - if I use a command a lot that is implemented in AHK called from "PUFF ", but where there are enough command misrecognitions that making it visible to KnowBrainer/Dragon seems like a good idea.


We have also come up with a temporary solution to prevent KnowBrainer from potentially causing Dragon to freeze. For the time being, please launch Dragon before launching KnowBrainer and you should be good to go.


(1) What? KnowBrainer causes Dragon to freeze?! Actually, in my various debug efforts I have become thinking more and more likely that some feedback loop involving KnowBrainer and Dragon is causing some of the problems. But since I am much less confident about this on Windows than I would be on UNIX where I know some of the tools to trace out such live/deadlocks, I have been reluctant to say so.

Q: in what circumstances does KnowBrainer cause Dragon to freeze?

Q: is always a true freeze, or is it possible that it is a hang state that some timeout eventually causes to exit? I regularly see hangs of five minutes, sometimes as long as 45 minutes, and I see so many hangs of the same duration that it really makes me think there is some timeout that is breaking up a dead or alive lock.

Q: What you mean by "start Dragon before KnowBrainer"?

OK, that's obvious -  but I suspect this means that SpeechStart+ RESTART DRAGON  did not be used? Since as far as I can tell RESTART DRAGON  effectively has KnowBrainer start before Dragon.

Q:  Is it possible that this potential  KnowBrainer--freeze-of-->Dragon  might explain some of the RESTART DRAGON problems that I have been experiencing? 

Q: how long has this  potential problem existed?   If in the last few months, it does not explain the problems I was having  a year or so ago.

Q:  Do you have an  issues database  visible-to-your-customers  with reports like this?    it might have saved me some time, if, indeed, the problems I have encountered  are the same as similar this potential KnowBrainer--freeze-of-->Dragon.

 



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

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.



 09/22/2020 12:59 AM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 37992
Joined: 10/01/2006

Only when you edit or create a new command will you experience the delay but it only occurs once. From then on command deployment will be quick. Also note that we are working on the problem and it has already been cut by 50%. We should have a better solution soon.

VerbalBasic is KnowBrainer's most important feature so we can assume that you're hand typing your macros. VB II is easier than typing; not to mention 30 times faster. We recommend checking out VB II on page 36 of the KnowBrainer Manual before asking us to remove our life's work which is the primary reason for creating KnowBrainer. Having said that, you can only delete one command at a time from the KnowBrainer Command Browser and there are over 400. However, if you know how to edit the C:\Users\Lunis Orcutt\AppData\Roaming\KnowBrainer\KnowBrainerCommands\MyKBComands.XML file the process can be done quickly because you would be removing all KnowBrainer and Dragon application specific commands. You should probably make a backup copy before attempting to edit this file but it can definitely be edited. We realize that you're looking for a checkbox option which we would also like but it's on the KnowBrainer 2021 to do list. There simply wasn't time to put everything we wanted in KnowBrainer 2017 (w/2020 AI Commands). We recommend waiting for the solution we are currently working on. 


From what we can tell, KnowBrainer is no longer causing Dragon to freeze but if you're not certain, launch Dragon 1st and then KnowBrainer. This should be a non-issue from our last command prune job but we are also considering moving the Dragon VerbalBasic commands directly into Dragon, now that Nuance has finally switched to WinWrap Basic scripting. KnowBrainer is no longer causing Dragon to freeze so this is a non-issue but we are waiting for our programmer to tell us if we need to remove VerbalBasic for Dragon (not for KnowBrainer), out of KnowBrainer and into Dragon or not. We're waiting because our programmer might have a better solution and this is his wheelhouse.  Until then we are on hold and ask for your patience. 


If your computer is hanging for 45 minutes, you definitely have a different problem. KnowBrainer may be exasperating the problem but we don't see how it could be problem. No one else is reporting these issues anymore. We conducted 3 remote installations today and saw no execution problems. One computer was notably slower but it was and i3 with 4 Gb of RAM. This was to be expected. 

SpeechStart+ can only launch KnowBrainer 1st. You would have to manually launch Dragon followed by launching KnowBrainer. However, this problem has already been resolved but could use improvement. Launching KnowBrainer doesn't freeze Dragon and as previously noted, is a non-issue.


The KnowBrainer Dragon freeze issue was very temporary. We believe it was a few weeks ago when we released VB II and we have since partially repaired the problem and will have a permanent fix shortly. If you have have experienced this problem for more than a month, you have a different problem that needs to be dealt with. At most, KnowBrainer could only be the catalyst. 


The best place to report problems are right here. We don't need a database because were not like Nuance who needs a list of problems to repair in X amount of years. When you report a KnowBrainer problem to us, we work on it 16 hours a day until it's done. Granted, we should've caught the Dragon freezing issue but it was fixed in 3 days, with a partial repair. We have a feature database for future improvements but bug fixes are typically handled immediately and in some cases, less than 60 minutes. That's why we don't really need a database. Being small isn't always an advantage but we can at least be quick about problem solving and we have verified that KnowBrainer isn't freezing Dragon. If possible, we recommend installing KnowBrainer and Dragon on another computer.


 



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

Forum Mission Statement
Trial Downloads
Dragon/Sales@KnowBrainer.com 
(615) 884-4558 ext 1

 09/22/2020 10:38 AM
User is offline View Users Profile Print this message

Author Icon
Ag
Top-Tier Member

Posts: 449
Joined: 07/08/2019

Q: when KnowBrainer froze Dragon as you describe, what was the user to do?

RESTART DRAGON?

and if that failed, kill Dragon/Knowbrainer or restart the PC ?

If the last two, could that have resulted in a "profile corruption"?

I doubt that the profile would be in process of being saved while this freeze was going on, so I would expect that this freeze could not of caused a profile corruption. Is that correct?

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

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.

 09/22/2020 07:08 PM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 37992
Joined: 10/01/2006

When KnowBrainer froze Dragon (as in the past but not now), we waited 20 seconds for Dragon to recover. We didn't usually have to crash Dragon. This is no longer a problem but Dragon crashes once a week, if KnowBrainer is running or not. However, we typically leave Dragon, our computer and 15 Gb of utilities running for a week before rebooting. We suspect that we are the problem rather than Dragon or our computer


When Dragon crashes, it is unlikely to damage the user profile because it is loaded into RAM and not in the middle of saving your profile. This is 1 of the reasons we don't allow Dragon to save our profile when shutting down. We have only suffered one corrupt user profile in 22 years; we believe it was Medical 10. We use Dragon from 70 to 90 hours a week and never optimize. We save our profile every time we make a change to our vocabulary but not when closing Dragon or rebooting.



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

Forum Mission Statement
Trial Downloads
Dragon/Sales@KnowBrainer.com 
(615) 884-4558 ext 1

 09/22/2020 11:40 AM
User is offline View Users Profile Print this message

Author Icon
R. Wilke
Top-Tier Member

Posts: 7227
Joined: 03/04/2007

I doubt that the profile would be in process of being saved while this freeze was going on, so I would expect that this freeze could not of caused a profile corruption. Is that correct?


This is not correct. During the session, Dragon keeps a whole lot of things related to the profile, especially related to the vocabulary which is the major part of it, going in memory, and needs to put them together and cleanup regularly at shutdown. "Killing" Dragon is meant literally. It should always be applied only as a last resort. Or would you consider shutting down Windows by pulling the plug a clean way of shutting it down? And keep in mind that the Windows developers spent a lot more resources taking precautions.

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



No need to buy if all you want to do is try ...

DragonCapture KB Download (Latest)
DragonCapture Homepage

 09/25/2020 05:07 PM
User is offline View Users Profile Print this message

Author Icon
Ag
Top-Tier Member

Posts: 449
Joined: 07/08/2019

Originally posted by: R. Wilke
I doubt that the profile would be in process of being saved while this freeze was going on, so I would expect that this freeze could not of caused a profile corruption. Is that correct?
This is not correct. During the session, Dragon keeps a whole lot of things related to the profile, especially related to the vocabulary which is the major part of it, going in memory, and needs to put them together and cleanup regularly at shutdown. "Killing" Dragon is meant literally. It should always be applied only as a last resort. Or would you consider shutting down Windows by pulling the plug a clean way of shutting it down? And keep in mind that the Windows developers spent a lot more resources taking precautions.

 

I think that what you describe  would only be a problem if Dragon is regularly saving some but not all of the  changes related to the state to disk.  so that if you killed at a random point of time, the profile  on disk is only partially updated, and hence corrupt.

 

If Dragon only saves modified profile state from memory to disk at shutdown or when explicitly asked,  then it is only a problem if you kill Dragon after such a state save has started and before it finished.

 

So that is part of what I'm asking:  does Dragon only save state disk at shutdown or "save user profile",  or is it continuously saving? 

 

--

 

Nevertheless, your point is quite valid: modern operating systems  like Windows and applications like ...  definitely Google Chrome,  to some extent  Microsoft OneNote ...  have definitely paid more attention to not corrupting  stuff stored on disk due to surprise shutdowns or kills than Dragon has.   most resilient applications use database storage, with transaction rollback, while Dragon uses files, although  there are certainly file based applications that are resilient.

 

Anyway, I would  much rather not ever have to kill Dragon. Nevertheless, when Dragon and SpeechStart+ are hung, or at least are taking >15 minutes for a command,  more time than I want to wait, what do I do? Is it better to run the kill Dragon script, or restart the entire PC?

 

I know, I know, you keep telling me that nobody else has ever seen such stalls,  and that it is undoubtedly user error on my part.  Perhaps you are right.  If so, I would certainly like to find out what  my user errors are.  On the other hand, I have found at least one way of consistently  crashing every version of Dragon  I have tried it on - the reentract "foo\foo as in bar" custom word -  despite being told  that nobody else ever saw any bugs like that.

 

BTW,  if the statement "nobody else has ever seen such stalls"  is changed slightly to "nobody else has ever seen such stalls, WHO CONTINUES TO USE DRAGON REGULARLY",  it is almost tautological. 

 

 

 

 



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

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.

 09/23/2020 12:03 PM
User is online View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 915
Joined: 04/03/2009

Originally posted by: Ag 

 

This weekend I wrote quite a few nice operations for KnowBrainer, by writing a single KnowBrainer command "PUFF Window ", ShellExecute'ing a single AutoHotKey script which did all the work, including the command parsing.

 

Yesterday I did the same thing with C#. Currently I have a single Dragon command (its name will probably change - dingle, obscure word for a small dell, is easy to say and I will never use it otherwise but I am used to zotz). Currently:
dingle <dictation>

maybe changing to:
<stateTrigger> <dictation>
with the list "stateTrigger" consisting of things like:
c/c
c/C
c/sea
c/Sea
c/see
c/See
c/c++
c/C++
c/sea++
c/Sea++
c/see++
c/See++
c/c plus plus
c/sea plus plus
[… including all the other obvious combinations:
C & C++ share a common syntax and will share the same "state"]
c#/C#
c#/sea sharp
[… All the other obvious combinations for C#]
html/HTML
basic/Basic
basic/basic
scite
scite/AutoIT
Dragon
Dragon/KnowBrainer


The application will save the programming language in an application Setting and will assume that's what you want until you change it by saying:
"dingle <stateTrigger> set"

Currently, just for testing, I'm assuming that the "state" is C# so I might say something like "dingle [simple | compound] for [constructor]",  or "dingle [simple | compound] if [constructor]. The application will create the appropriate empty "template", copy it to the clipboard then paste the clipboard into Visual Studio (which REALLY hates SendKeys and its country cousins SendDragonKeys & SendSystemKeys).


I suppose I'm reinventing the wheel but at least this way I can tune the spokes; use dynamic, not static balancing; run a racing tire and ensure proper inflation!

 



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

-Edgar
DPI 15.3, 64-bit Windows 10 Pro, OpenOffice & Office 365, Norton Security, Shure X2U XLR to USB mic adapter with Audio Technica DB135 vocal mic, Asus X299-Deluxe Prime, Intel Core i9-7940X (14 core, 4.3 GHz overclocked to 4.9 GHz), G.SKILL TridentZ Series 64GB (4 x 16GB) DDR4 3333 (PC4 26600) F4-3333C16Q-64GTZ, NVIDIA GIGABYTE GeForce GTX 1060 GV-N1060G1 GAMING-6GD REV 2.0 6GB graphics card with 3 1920x1080 monitors

 09/23/2020 01:18 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2072
Joined: 03/21/2007

One comment, I wouldn't load up on list options the way you do. I'd have just one, do it right, and ask Dragon to recognize it when said.

So, if the state is "c" - and btw state names are arbitrary and have no semantic value (except as I showed here) or else "c#" (which to avoid symbols, I'd use "csharp," or if you did ever need it, "cplusplus"), then I would have just:

c\C
cplusplus\C plus plus
csharp\C sharp

And avoid homonyms like "sea" (and "Sea?") which in my mind in the long run confuses Dragon. Simply put, Dragon is supposed to recognize "C" in an utterance. If you have a list with those three entries and use it in a command "set state [stateTrigger]" the command will be recognized (since the audiogram for sea and C are no different anyway).



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




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.



 09/23/2020 03:36 PM
User is online View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 915
Joined: 04/03/2009

Originally posted by: PG LTU One comment, I wouldn't load up on list options the way you do. […] btw state names are arbitrary and have no semantic value (except as I showed here)

In reverse order… These "states" are saved in an applications Settings (see here:
https://docs.microsoft.com/en-us/visualstudio/ide/reference/settings-page-project-designer?f1url=%3FappId%3DDev15IDEF1%26l%3DEN-US%26k%3Dk(ApplicationSettingsOverview);k(TargetFrameworkMoniker-.NETFramework,Version%253Dv4.6.1)%26rd%3Dtrue&view=vs-2019). They are variables and their names are somewhat structured (they must be printable strings, they must not start with a digit and some punctuation is not allowed).

I often see that Dragon gets confused with words like "sea" and "see"; if I have a command which has "sea" (but not
 "see") within a list Dragon often fails to recognize the command. Instead it types out the dictation with the inappropriate "see" which probably has much higher probability given the utterance. YMMV! I know I am a "belt & suspenders" kind of programmer.



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

-Edgar
DPI 15.3, 64-bit Windows 10 Pro, OpenOffice & Office 365, Norton Security, Shure X2U XLR to USB mic adapter with Audio Technica DB135 vocal mic, Asus X299-Deluxe Prime, Intel Core i9-7940X (14 core, 4.3 GHz overclocked to 4.9 GHz), G.SKILL TridentZ Series 64GB (4 x 16GB) DDR4 3333 (PC4 26600) F4-3333C16Q-64GTZ, NVIDIA GIGABYTE GeForce GTX 1060 GV-N1060G1 GAMING-6GD REV 2.0 6GB graphics card with 3 1920x1080 monitors

 09/23/2020 04:11 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2072
Joined: 03/21/2007

As to commands with "sea" that aren't recognized because Dragon types "see," that won't happen anymore in a brand new profile as long as "sea" is not a list element and only "C" is.

Believe me, I've been testing this since 2007 because under the old models that seemed to be necessary. But even then, if you played around with it for too long, changing, training and taking different but overlapping approaches was sure to wreak havoc. Every time I tried commands with numbers in them, after testing and trying things out, "choose [some number or another]" would stop working and you'd have to write a command to "pick [that number]" which then did the heardword for it and you hoped it worked bc new profiles were more burdensome.



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




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.



 09/23/2020 05:15 PM
User is online View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 915
Joined: 04/03/2009

Originally posted by: PG LTU As to commands with "sea" that aren't recognized because Dragon types "see," that won't happen anymore in a brand new profile as long as "sea" is not a list element and only "C" is.

I just tried this and unfortunately this is not completely* fixed in 15.3. Even though "see" is not in the list it is given preferential treatment in a similar command with an open ended (<dictation>) style:

dingle <dictation>

dingle <stateTriggers> set

if I say "dingle c set" (with "c" as the only c-related item on the list) it triggers the first. *However, if I change the "c" into "C" it does work - good enough. C Sharp is another problem - Dragon refuses to dictate "C#" into its list editor - one must enter it letter by letter. However, once entered it works just fine.



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

-Edgar
DPI 15.3, 64-bit Windows 10 Pro, OpenOffice & Office 365, Norton Security, Shure X2U XLR to USB mic adapter with Audio Technica DB135 vocal mic, Asus X299-Deluxe Prime, Intel Core i9-7940X (14 core, 4.3 GHz overclocked to 4.9 GHz), G.SKILL TridentZ Series 64GB (4 x 16GB) DDR4 3333 (PC4 26600) F4-3333C16Q-64GTZ, NVIDIA GIGABYTE GeForce GTX 1060 GV-N1060G1 GAMING-6GD REV 2.0 6GB graphics card with 3 1920x1080 monitors

 09/23/2020 04:26 PM
User is online View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 915
Joined: 04/03/2009

Actually, I do believe you! When it comes to Dragon 15+ things are certainly much better. Unfortunately, I so often have to support Dragon 13 & 14 that I maintain my old habits. I'm just getting ready to create the aforementioned Dragon script in 15.3 and will do so without the exhaustive versions of "c". Given that I spend many hours a day programming this script will get a heavy workout!

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

-Edgar
DPI 15.3, 64-bit Windows 10 Pro, OpenOffice & Office 365, Norton Security, Shure X2U XLR to USB mic adapter with Audio Technica DB135 vocal mic, Asus X299-Deluxe Prime, Intel Core i9-7940X (14 core, 4.3 GHz overclocked to 4.9 GHz), G.SKILL TridentZ Series 64GB (4 x 16GB) DDR4 3333 (PC4 26600) F4-3333C16Q-64GTZ, NVIDIA GIGABYTE GeForce GTX 1060 GV-N1060G1 GAMING-6GD REV 2.0 6GB graphics card with 3 1920x1080 monitors

 09/23/2020 05:17 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2072
Joined: 03/21/2007

Well I'd be curious to know how you make out (with a new profile in particular). I believe you should use "C" (capitalized) for the spoken form as that is what Dragon expects. Btw, it is easy to figure out what Dragon expects. In this case, open the Vocabulary Editor and note Dragon always uses "C" when it means the letter.


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




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.

 09/23/2020 05:24 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2072
Joined: 03/21/2007

Oh - forget everything I said if you are using open dictation! I meant for list commands. List commands become part of the command vocabulary and this help "C" take precedence since Dragon _has a command phrase to match_. Open dictation has no way of knowing which is more useful, "C" or "sea" if your are just sendkeying or doing something with the list result.

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




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.

 09/25/2020 05:13 PM
User is offline View Users Profile Print this message

Author Icon
Ag
Top-Tier Member

Posts: 449
Joined: 07/08/2019

Originally posted by: PG LTU Oh - forget everything I said if you are using open dictation! I meant for list commands. List commands become part of the command vocabulary and this help "C" take precedence since Dragon _has a command phrase to match_. Open dictation has no way of knowing which is more useful, "C" or "sea" if your are just sendkeying or doing something with the list result.

Good, I was a little bit confused by the difference between what Edgar was saying and what you are saying PG_LTU.   but let me just check:

 

Edgar:  I think you are saying that you are doing lots of  "dingle <dictation>" commands, and in whatever code is invoked by "dingle <dictation>",  which I assume when your case is usually C#,  you are doing mode or state specific commands , using a state that you have set by "dingle <state> set". Here I have changed s/stateTrigger/state/ because I was initially confused by stateTrigger).

 

Where "state"  is something that you have  implemented yourself.  You are not using Dragon states or anything like that.

 

I was a bit confused by your stateTrigger list, but then I realized that was just a Dragon list (with aliases) to set your non-Dragon state.

 

Am I close?

 

Whereas when PG_LTU referred to his post Auto numbering websites using Dragon States He was talking about, well,  Dragon states,  which are a different thing.  

 

Dragon states live inside Dragon, and can interact with recognition, affecting the command of vocabulary.

 

Whereas the states that you are using, Edgar, are outside Dragon  and do not affect command vocabulary -  either they are only as good as dragons <dictation>, or  you have to do some filtering inside your code.

 

E.g.  inside my similar code,  which is not yet stateful, I am matching on things like (right|write)  or some command names.  Actually, I am doing s/right/write/,  so that I only have to do the transformation wants, not every pattern.

 

This is the fundamental and unfortunate trade-off when you start moving recognition of commands outside the Dragon command vocabulary.

 

I have not yet tried using states, neither in my commands nor in Dragon.   Well, at least not state that I explicitly store and manipulate myself -  I am using  the greater variety of states that AHK makes available, not just WinActive, but WinExists, regexp matching on window titles, executable names, etc.   Looking at the focused control - although annoyingly that very seldom distinguishes what I care about,  e.g. the need to admit different SendKeys depending on whether I am in a  message pane or a folder pane ib Thunderbird. I *have*  started using tricks like doing different CapsLock  and other shift  management depending on whether  windows of particular names are open.

 

Edgar: In the past you said that you store such stuff in files,  and now here I see that you are storing stuff in "Application Settings".  That's interesting: is it significantly faster than files? I.e. do they do some sort of caching?   perhaps some caching that persists  across different  invocation of commands  that share the same "Application Settings".

 

 I have trouble imagining  constantly reading and re-parsing a file to be fast enough for interactive commands. (I might be wrong: modern computers are so darn fast.  except when they are not -  which is why I have a job.) But if there is some way of  saving that persistently,  it sounds good.

 

Failing that,  I have been thinking of communicating between an AHK script that Dragon/KnowBrainer invoke, and a persistent script.  

 

 

 

 

 

 

 

 

 

 

 



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

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.

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

Author Icon
kkkwj
Top-Tier Member

Posts: 497
Joined: 11/05/2015

I just reread this thread, and came across the comments about the slowness of this common pattern in Basic to parse the list variable. This particular version is slow because of the way it is written - it will always execute all 100 of the tests because of the way it is written.

 

  • if ListVar1 = "1" then SendKeys "[01]"
  • ...
  • if ListVar1 = "99" then SendKeys "[99]"
Instead, it should be written using the "if ... then ... elseif ... endif" style, like so:
if ListVar1 = "1" then
   SendKeys "[01]"
elseif ListVar1 = "2" then
   SendKeys "[02]"
...
else if ListVar1 = "99" then
   SendKeys "[99]"
endif
On average, and assuming an equal distribution of incoming numbers, this pattern would only execute half of the list each time and would be twice as fast. If you knew which incoming numbers were more frequently used, you could put the most frequently used ones at the beginning, which would drastically reduce execution time once again. Finally, if you really wanted to collect statistics, you could put a counter in each branch and track the frequency of use for a month or so. That would give you some data to guide your ordering of the list.
Another way to speed things up would be to inspect the first character and length of the incoming ListVar. That would enable you to route the number to one of ten branches (0,10,20,etc.) that each had ten subbranches (0-9). That method would limit your tests to probably four or five, instead of doing 100 as in the original code example.


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

Win10/x64, AMD Ryzen 7 3700X, 64GB RAM, Dragon 15.3, SP 6 PRO, SpeechStart, Office 365, KB 2017, Dragon Capture, Samson Meteor USB Desk Mic, Klim and JUKSTG earbuds with microphones



 09/26/2020 11:59 AM
User is online View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 915
Joined: 04/03/2009

Originally posted by: Ag  Edgar:  I think you are saying that you are doing lots of  "dingle " commands, and in whatever code is invoked by "dingle ",  which I assume when your case is usually C#,  you are doing mode or state specific commands , using a state that you have set by "dingle set". Here I have changed s/stateTrigger/state/ because I was initially confused by stateTrigger). 

Where "state"  is something that you have  implemented yourself.  You are not using Dragon states or anything like that.

 

Am I close?

[…]

E.g.  inside my similar code,  which is not yet stateful, I am matching on things like (right|write)  or some command names.  Actually, I am doing s/right/write/,  so that I only have to do the transformation wants, not every pattern.

[…] 

Edgar: In the past you said that you store such stuff in files,  and now here I see that you are storing stuff in "Application Settings".  That's interesting: is it significantly faster than files? I.e. do they do some sort of caching?   perhaps some caching that persists  across different  invocation of commands  that share the same "Application Settings". 

 I have trouble imagining  constantly reading and re-parsing a file to be fast enough for interactive commands. (I might be wrong: modern computers are so darn fast.  except when they are not -  which is why I have a job.) But if there is some way of  saving that persistently,  it sounds good.

 

In my original C# code I was using the variable name "state" but realized it was semantically confusing with Dragon’s "State"s so when I started talking about the concept I changed my variable name to "stateTrigger" to help avoid confusion. As you realized these are application-internal "states" and are maintained in an application-specific "Setting".

Here's a tiny bit of C# code which I wrote yesterday but has not been tested:

      Public Class TargetWords {
         Public Static List<String> mHomonymsList = New List<String>();

         Public TargetWords() {
            mHomonymsList.Add("and,an");
            mHomonymsList.Add("do,due");
            mHomonymsList.Add("equal,equals,=");
            mHomonymsList.Add("for,four,4");
            mHomonymsList.Add("greater,larger,bigger");
            mHomonymsList.Add("integer,int");
            mHomonymsList.Add("is,his");
            mHomonymsList.Add("less,smaller");
            mHomonymsList.Add("not,knot,naught");
            mHomonymsList.Add("or,ore,oar");
            mHomonymsList.Add("period,dot,.");
            mHomonymsList.Add("than,then");
            mHomonymsList.Add("to,two,too,2");
         }

         Public String GetTargetWord(String pPotentialWord) {
            String bestWord = pPotentialWord;

            foreach (String homonyms In mHomonymsList) {
               If (homonyms.Contains(pPotentialWord)) {
                  String[] homonymsArray = homonyms.Split(',');
                  bestWord = homonymsArray[0];
                  break;
               }
            }
            return bestWord;
         }
      }

Normally, mHomonymsList would be filled by reading from a text file but, as of now, the number of strings is minimal and I am going to try maintaining it this way. Here's how it is used:

      [STAThread]
      Static void Main(String[] args) {
         TextInfo textInfo = New CultureInfo("en-US", True).TextInfo;
         TargetWords targetWords = New TargetWords();

         If (foregroundWindow == IntPtr.Zero) {
            MessageBox.Show("No foreground window could be found!", "Non-recoverable ERROR",
               MessageBoxButtons.OK, MessageBoxIcon.Error);
            return;//bail out
         }

         foreach (String word In args) {
               If (!(String.Compare(word, "constructor", True) == 0)) {
                  String bestWord = targetWords.GetTargetWord(textInfo.ToLower(word));
                  phrase = String.Concat(phrase, textInfo.ToLower(word), " ");
               }
         }
         phrase = phrase.TrimEnd(' ');
         wordsInPhrase = phrase.Split(' ');
         If ((wordsInPhrase.Length == 2) && (String.Compare(wordsInPhrase[1], "XXXSetStateXXX", True) == 0)) {
            Settings.Default.State = wordsInPhrase[0];
            Settings.Default.Save();
            Application.Exit();
         }
         Else
            DoCommand();
      }

      Private Static void DoCommand() {
         switch (phrase) {
            //[...quite a few cases removed to shorten the example]
            Case "if else compound":
               SendKeys.SendWait("if {(}{)} {{}{Enter}{}}{Enter}else {{}{Enter}{}}{Up 3}{End}{Left 3}");
               break;
            Case "if else this compound":
               SendKeys.SendWait("if {(}{)} {{}{Enter}{}}{Enter}else {{}{Enter}{}}{Up 3}{End}{Left 3}");
               SendKeys.SendWait("^v");
               SendKeys.SendWait("{END}");
               break;
            Case "for":
               SendKeys.SendWait("for {(}variableType i = 0; i CONDITIONAL XXX; i{+}{+}{)} {{}{ENTER}{}}{UP}{Home}{RIGHT 5}+^{RIGHT}+{LEFT}");
               break;
            Case "for integer":
               SendKeys.SendWait("for {(}int i = 0; i CONDITIONAL XXX; i{+}{+}{)} {{}{ENTER}{}}{UP}{Home}{RIGHT 5}+^{RIGHT}+{LEFT}");
               break;
            Case "for each":
               SendKeys.SendWait("foreach {(}ClassType variableName in whatList {)} {{}{ENTER}{}}{UP}{Home}{Right 9}^+{RIGHT}+{LEFT}");
               break;
            Case "try":
               SendKeys.SendWait("try {{}{Enter}{}}{ENTER}");
               SendKeys.SendWait("catch {(}Exception pException{)} {{}{ENTER}");
               SendKeys.SendWait("MessageBox.Show{(}string.Format{(}\"MESSAGE: {0}\", pException.ToString{(}{)}{)}, \"TITLE\", MessageBoxButtons.OK, MessageBoxIcon.Error{)};{ENTER}");
               SendKeys.SendWait("{}}{UP 4}{END}{Enter}");
               break;
            //[...many cases removed to shorten the example]
            Default:
               SendKeys.SendWait(phrase);
               break;
         } 

      }

As for application settings, they are stored on disk in the user’s AppData folder and, while from the documentation it's not clear, I think they could be shared between different applications, but I do not do so. Windows is very good at noticing when a file is referenced from disk repeatedly and keeps it in RAM if possible. In addition to that, I use a free application ("ImDisk") to mount a small (4 GB/64 GB - I'm only using a tiny fraction of the 4 GB for these scripts but I also use it when converting large video/audio files) RAM disk from which I am executing both my "Correct That" replacement application "CoryJ" and this "dingle" executable.

One thing about using a C# program - you get Unicode almost for free; another is that SendKeys timing is managed by the OS and, Clipboard operations (SendKeys ("^v") etc.) is virtually instantaneous and requires no waiting as it does in all the other Basic-based script languages I've tried (Dragon, KnowBrainer, AutoIT, DesignCAD’s BasicCAD etc.)



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

-Edgar
DPI 15.3, 64-bit Windows 10 Pro, OpenOffice & Office 365, Norton Security, Shure X2U XLR to USB mic adapter with Audio Technica DB135 vocal mic, Asus X299-Deluxe Prime, Intel Core i9-7940X (14 core, 4.3 GHz overclocked to 4.9 GHz), G.SKILL TridentZ Series 64GB (4 x 16GB) DDR4 3333 (PC4 26600) F4-3333C16Q-64GTZ, NVIDIA GIGABYTE GeForce GTX 1060 GV-N1060G1 GAMING-6GD REV 2.0 6GB graphics card with 3 1920x1080 monitors

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

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