KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: Open-ended dictation parser for injecting code snippets
Topic Summary:
Created On: 02/10/2021 06:12 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/10/2021 06:12 PM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/14/2021 02:38 PM  
 Open-ended dictation parser for injecting code snippets   - kkkwj - 02/14/2021 10:30 PM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/15/2021 10:38 AM  
 Open-ended dictation parser for injecting code snippets   - kkkwj - 02/15/2021 09:13 PM  
 Open-ended dictation parser for injecting code snippets   - kkkwj - 02/16/2021 02:34 AM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/16/2021 01:29 PM  
 Open-ended dictation parser for injecting code snippets   - kkkwj - 02/16/2021 05:44 PM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/17/2021 11:12 AM  
 Open-ended dictation parser for injecting code snippets   - kkkwj - 02/17/2021 11:39 AM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/17/2021 02:53 PM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/19/2021 11:43 AM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/19/2021 06:35 PM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/19/2021 07:18 PM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/19/2021 07:24 PM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/19/2021 07:49 PM  
 Open-ended dictation parser for injecting code snippets   - lifeisgood - 02/20/2021 10:13 AM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/20/2021 10:40 AM  
 Open-ended dictation parser for injecting code snippets   - LexiconCode - 02/22/2021 08:02 AM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/22/2021 11:00 AM  
 Open-ended dictation parser for injecting code snippets   - LexiconCode - 02/22/2021 12:49 PM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/22/2021 03:26 PM  
 Open-ended dictation parser for injecting code snippets   - kkkwj - 02/23/2021 07:23 PM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/23/2021 08:47 PM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/23/2021 08:51 PM  
 Open-ended dictation parser for injecting code snippets   - kkkwj - 02/23/2021 10:12 PM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/24/2021 11:15 AM  
 Open-ended dictation parser for injecting code snippets   - kkkwj - 02/24/2021 11:30 AM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/24/2021 02:03 PM  
 Open-ended dictation parser for injecting code snippets   - kkkwj - 02/24/2021 03:06 PM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/24/2021 06:00 PM  
 Open-ended dictation parser for injecting code snippets   - kkkwj - 02/24/2021 09:19 PM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/25/2021 11:11 AM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/26/2021 10:23 AM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/26/2021 01:34 PM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/26/2021 03:49 PM  
 Open-ended dictation parser for injecting code snippets   - tar - 02/26/2021 03:56 PM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/26/2021 08:28 PM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 03/21/2021 07:53 PM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/25/2021 11:41 AM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 02/25/2021 06:20 PM  
 Open-ended dictation parser for injecting code snippets   - kkkwj - 03/23/2021 02:30 AM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 03/23/2021 11:45 AM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 03/23/2021 12:00 PM  
 Open-ended dictation parser for injecting code snippets   - kkkwj - 03/23/2021 11:19 PM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 03/24/2021 12:49 PM  
 Open-ended dictation parser for injecting code snippets   - R. Wilke - 03/24/2021 05:03 PM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 03/28/2021 07:03 PM  
 Open-ended dictation parser for injecting code snippets   - kkkwj - 03/29/2021 11:59 AM  
 Open-ended dictation parser for injecting code snippets   - Edgar - 03/30/2021 07:08 PM  
Keyword
 02/10/2021 06:12 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

Here's a first stab at an open-ended dictation parser for coding in C#/C++. This is been discussed in a couple of different threads, most recently here:
https://www.knowbrainer.com/forums/forum/messageview.cfm?catid=12&threadid=35392&enterthread=y&STARTPAGE=3&discTab=true

 

 

Unfortunately the code was too long to survive posting, see my follow-on post…



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

-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



 02/14/2021 02:38 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

It seems that the amount of text that I pasted was too much for this forum.

It also turns out that the solution did not scale up well. My original tests were with a Dictionary of between 200 and 300 entries - all was well. I then added a lot more entries (465 total). Without changing anything else, other than the total number of cases, things went pear-shaped! There was clearly a timing problem as it worked fine under the debugger but the Release version just sent the target window off into a long sleep (minutes). Even putting a MessageBox in the Release version (displayed immediately after parsing the utterance and just before the switch) was enough to make the application work just fine.

I tried lots of hacks: a simple Thread.Sleep() statement with times running from 10 (milliseconds) to some gigantic number which worked out to about 5 seconds; a do/while which just incremented a throwaway variable; (both failed); and finally a "Visualizer" window run in a separate thread with a built-in timeout (this worked with the timeout failing with 60 ms and succeeding with 70 ms). I found it helpful with debugging anyway when I set the timeout to be about 1.5 seconds and a single label in the window whose text was the utterance.

This is lightning fast! In Visual Studio it NEVER crashes Dragon/KnowBrainer. Because I still have a lot of "Zotz" commands that I have not weeded out of KnowBrainer, and as a nod to AG, I have created a Dragon command: Puff <dictation>. I won't bother to post the code unless somebody asks for it.



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

-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

 02/14/2021 10:30 PM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 801
Joined: 11/05/2015

Hi Edgar, it sounds like you had a dictionary implementation of 200-300 named snippets and then doubled it to 465 snippets/commands. I don't understand what the problem is, since a dictionary of that size is basically nothing to worry about. And since you're only sending one snippet regardless of which of the 465 were chosen, it's not like you're sending any more text to the window. And then first you say it continually hung the target window, then you say "This is lightning fast!", and then it sounds like you're using it anyway.


Could you please explain more? And I am interested in your C# code if you'll zip it up somewhere. Maybe I can offer some suggestions. It almost sounds like you're catching the utterance in Dragon, redirecting it to your program with "Puff ", and then having your program generate and send the snippet keys to the target window. I do something similar (I suppose) for sending short text words to unfriendly apps, but I don't do anything with snippets.

If it helps any, I remember a posting on StackOverflow from a guy who wanted to slow down the send rate of SendKeys because whatever he sent was too fast for the target window to receive. Maybe that's what is going on with your code?

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

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, 3 BenQ 2560x1440 monitors, Microsoft Sculpt Keyboard and fat mouse

 02/15/2021 10:38 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

Originally posted by: kkkwj I don't understand what the problem is, since a dictionary of that size is basically nothing to worry about. […]

And then first you say it continually hung the target window, then you say "This is lightning fast!", and then it sounds like you're using it anyway. Could you please explain more? […]

I am interested in your C# code

Lastly, I have attached the zipped full solution.

Firstly, I have no idea why, but the only thing I changed in the code was doubling the size of the dictionary and (almost) doubling the number of cases in the switch statement. Before the change it was working perfectly - very fast and never hanging Visual Studio (nor any of the other test target windows). After the change, the target window (I tried Visual Studio, Notepad and PSPad in all of my testing) looked like it had lost focus and was "not responding". I waited 30 seconds or so and, being the impatient kind of guy that I am, used the Task Manager to "end task" the "StatementConstructor" application. At that time, the target window regained focus and was happy to receive additional dictation. On one test, just before using the Task Manager my dog decided that she absolutely, positively had to go outside "Right now!"; leaving the target window hung, I left my computer to let her out. Coming back a few minutes later I saw the target window regain focus and become responsive and noted that the application was no longer running (looking at the Task Manager). <Shrug>

Secondly, the current code is working incredibly well again. I have a global Dragon open ended dictation command (Puff <dictation>) which does nothing but ShellExecute the application sending the entire <dictation> to it on the command line:
ShellExecute "Z:\StatementConstrucor\StatementConstructors.exe " & ListVar1

(of course you would need to modify this for the location of your executable).

This new version of the command has a "Visualizer" window which displays the utterance VERY briefly (~70 µs) before automatically closing. This resolves the timing issue. It also has a "what can I say?" dialog. If your utterance is "what can I say" the application opens the dialog which displays all of the utterances it recognizes - constructing this dialog takes my computer a long time (5 seconds or so).

The utterance parser is also now a tiny bit AI - if you say "static public" or "static private" as part of your utterance it will ALWAYS resolve this as" public static" or "private static" respectively. This also allows me to force the exact spacing the way I want it, not the way Dragon wants.

I have tested all of the complicated utterances and all of the common usages (I did not bother to test every permutation of "public|private [static] variableType". If one extends the dictionary one would need to ensure that the number of pairs in the dictionary is exactly divisible by five (using the assumption that the "what can I say" dialog has five columns). If you look at the last few entries to the dictionary you will see that I have put in some "do nothing" entries to pad the total; and change the number of total rows displayed. Optionally, one could add smart code to handle the modulo remainder - not difficult.

BTW, this allowed me to remove almost 1000 commands from KnowBrainer! They were application specific to Visual Studio which showed up as two different applications (post-2008 it was:
  <Commands scope="application" module="devenv" company="Microsoft Corporation" moduleDescription="Microsoft Visual Studio 20xx">
where "devenv" was common to all. Pre-2010 the "module" was different (VCExpress 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

 02/15/2021 09:13 PM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 801
Joined: 11/05/2015

Thanks Edgar! It's really nice to see how you approach the snippet generation problem. I saw another Basic script that you posted earlier somewhere on the forum with about 20 or 30 branches in the case statement. But this version is obviously much larger.

 

On my machine it must take 20 seconds to dynamically generate the graphics for the What Can I Say panel. It was so slow that I thought the program hung. I ran a profiler on it, and the LayoutForms method takes up 99% of the user-level time.

 

I rewrote the panel code to use text instead of graphics and now it automatically calculates the number of display columns based on the screen resolution and displays instantly (with sorted dictionary values, if you want them).

 

The bad news is that I can't get the text insertion into the active window to work. I have the same loss of focus that you are talking about. The program cannot get hold of the "foreground window" (meaning the one you want the text to go into) by calling GetForegroundWindow. I get an empty title back.

 

I will investigate further; I have never tried this chain before: Dragon->ShellExecute->new process running some program->try to get the foreground window. That must work properly to insert keys. When I run the code below from Dragon->ShellExecute->myProgram, the dialog shows the foreground window class is #32770, which according to the net is an error dialog of some kind. It's definitely not the Visual Studio editor!

 

Ok, the solution was that your ShellExecute example above did not include the secret ", 7" WindowStyle argument that specified a minimized window and inactive. The code below works as desired. 

Sub Main
    Dim path As String
    path = "C:\some long path\bin\Debug\TestSendKeys.exe "
    ShellExecute path & ListVar1, 7
End Sub


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

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, 3 BenQ 2560x1440 monitors, Microsoft Sculpt Keyboard and fat mouse



 02/16/2021 02:34 AM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 801
Joined: 11/05/2015

Here is the updated code. It has two limitations compared to your description of the orginal code: 1) I could never get the pop-up visualizer "recognition box" to work because of thread abort exceptions in the dialog display code, so I commented it out. 2) I could not get the What Can I Say dialog to display in the foreground, even though it was being shown as a modal dialog. Bringing a new form to the foreground from a background process is difficult to do; I don't know how to do it from a ShellExecuted program running under Dragon.

 

The good news is that the text display of all the things you can say runs almost instantly. There are easy places to change the font family, size, and background color to suit your preferences.

 

If you can figure out a way to get it to display on top then it will be even easier to use. 






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

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, 3 BenQ 2560x1440 monitors, Microsoft Sculpt Keyboard and fat mouse

 02/16/2021 01:29 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

Originally posted by: kkkwj Here is the updated code. It has two limitations compared to your description of the orginal code: 1) I could never get the pop-up visualizer "recognition box" to work because of thread abort exceptions in the dialog display code, so I commented it out. 2) I could not get the What Can I Say dialog to display in the foreground, even though it was being shown as a modal dialog. Bringing a new form to the foreground from a background process is difficult to do; I don't know how to do it from a ShellExecuted program running under Dragon.

 

 

 

The good news is that the text display of all the things you can say runs almost instantly. There are easy places to change the font family, size, and background color to suit your preferences.

 

 

 

If you can figure out a way to get it to display on top then it will be even easier to use. 

 



Your code is elegant! Breaking it up into separate code files makes it much easier to work on. Your solution to finding the widest text width (though possibly not completely accurate - certainly close enough) reduces code and processing cycles.

Unfortunately your solution of using a single TextBox does not survive resizing the window smaller. It did not dig into the designer but I suspect that you might have docked your TextBox as "Fill". You need to figure out a way to not size the text box when the window sizes but to add scrollbars as needed. Probably easy to do.

I could not get your solution to actually work for pasting code snippets. The only method I tried was creating a Dragon® script and using ShellExecute. Your solution (with the visualizer commented out) fails in exactly the same way mine does with the visualizer commented out.

Since my preliminary offering is obviously open source (as would be anything that I released as "version 1.0"), I am going to shamelessly steal those portions of your solution which I find useful (unless you object). Thanks in advance <Grin>!



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

-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

 02/16/2021 05:44 PM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 801
Joined: 11/05/2015

Hi Edgar, thank you for the nice compliment about my elegant code. That is always nice for programmer to hear!

 

It was also nice to hear you say that breaking it up into separate files made it easierr to work on. I was worried about that a bit because did not know if multiple files would be harder for you to work on by voice. (I'm not a voice-only programmer, so I don't know how multiple files affect convenience.)


You are welcome to use the code that I contributed to your effort. Be sure to use the secret ", 7" in your ShellExecute call as I described in my post above. It pastes snippets fine for me.

You are correct - I did dock the text box with Fill, and I made no attempt to handle window resize events or to recalculate the column grid (which should be done on resize events anyway). My intent was to use the full surface of the screen to reduce scrolling to a minimum. After you look up the string you want to speak, I expected that you would all-tab away from the window, or close it completely.

I was thinking of it some more overnight and today. The problem with your approach is that the program is written as a console application, not as a true windows app. (I realize that the build options classified it as a window application, but it is not.) Your current architecture is [console app+child modal dialog], with the intent of having the modal dialog hang around long enough that you can look at it. When you close it, the whole thing closes and goes away.

But I think you would be much better off writing the panel as a true windows application that runs in its own process. That way, you can AppBringItUp or ShellExecute it and it will hang around naturally until someone closes it (which could be you). In other words, you can treat a true windows application just like a modal dialog for your purposes, but you will be doing it the right way.

My main point here is that you should split the current application into two separate applications. One to send the keystrokes to the buffer, and the other to show what you can say. They can both share the same dictionary strings in a class library. That way, you can have the best of both worlds. Create three projects in one visual studio solution - one class library to manage the dictionary, one console application to send the keys, and one Windows application to show what you can say. Then everything will be beautiful, and people from around the world will thank you profusely for your great code! :-)



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

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, 3 BenQ 2560x1440 monitors, Microsoft Sculpt Keyboard and fat mouse



 02/17/2021 11:12 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

I've come to the same conclusion about console/library/Window projects.

I blatantly stole many of your suggestions <grin>! Just FYI, the only reason I had it all in one file to begin with was that I hoped to just paste that file into a forum message - did not work, the post was too long. It's now split out into a handful of separate files. For now, I am not going to go with your concept of a single TextBox with columns. I timed it… here it takes 17 seconds for the "what can I say" dialog to open - obviously way too long even if there was some way to display a "busy" cursor (guidelines typically suggest a progress bar if more than 5 seconds). The apparent solution would be to create (using your column measurement code) multiple side-by-side TextBoxes, stick them in a Panel which does auto scrolling and then remember what size and location the user last preferred. Of course, if we are going to go the console/library/Window route we could add a preference dialog for things like font, text color and background color.

I separated the replacement parser out into its own separate function. It got quite a few replacements beyond the public/private static pairs: 2,two,too->to; due->do write,wright->right; etc. and abbreviated keywords like constant/const, integer/int, reference/ref which get normalized to their abbreviated form. Doing this I was able to remove about 100 dictionary entries.

Today it's going to get an AI subassembly:

IF utterance CONTAINS BOTH public AND private THEN fail gracefully.

PARSE utterance FOR KEYWORDS (constant | public | private | static | read-only | [boolean | character | double | float | <8/16/32/64 bit> integer | short | long <¿ long long?> | function) THEN remove duplicates THEN make sure that none of the possible conflicting plurals are there (you cannot have a "private static short float" because short and float are mutually exclusive) IF SO fail gracefully THEN IF all words in utterance have been considered THEN normalize the order (¿what is the appropriate normalized order?) and send them to the snippet printing routine OTHERWISE assume the rest of the utterance is a variable name (possibly prefaced by a modifier: camel (the default), Pascal, snake, capitals, member, global, parameter - those are the ones I use now) AND format the remainder of the utterance appropriately THEN normalize the order, mangle the variable name and combined it with the normalized string THEN send it to the snippet printing routine.

With this AI parsing I will be able to remove a huge number dictionary items - maybe even getting it down to where we do not need to abandon the layout panel (which is so time-consuming to construct and format).



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

-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

 02/17/2021 11:39 AM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 801
Joined: 11/05/2015

Wow, 17 seconds - you must be talking about the panel approach. On my machine, creating and displaying the text columns takes 156 milliseconds. I don't understand why you wouldn't use that approach - it's far faster, can be recalculated in an instant, and has all the capabilities of the panel approach (except maybe for fancy font graphics). It sounds like there are many more useful features to add with automatically converting non-keywords into variable names, and so on. That will save some utterances and increase programming speed, I imagine. I can hardly wait to see it!

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

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, 3 BenQ 2560x1440 monitors, Microsoft Sculpt Keyboard and fat mouse

 02/17/2021 02:53 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

Originally posted by: kkkwj Wow, 17 seconds - you must be talking about the panel approach.


Exactly, I have a Form containing a Panel (Dock as Fill, AutoScroll is True) which contains the much larger TableLayoutPanel. This allows the window to be resized and the scroll bars to respond automatically. Ripping it out and replacing it with something faster is currently fairly low priority as I already know "what I can say" <grin> and in reality was only coded to give me an excuse to learn how to do TableLayoutPanel layout.

I suspect that using your calculations for determining maximum column width and thus best number of columns, combined with making each column its own separate TextBox, will end up being the optimum solution.



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

-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

 02/19/2021 11:43 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

I spent a lot of time on this yesterday. I now have reduced the dictionary down to about two hundred fifty entries. I have three functions which trigger one after the other:

1) massage the input utterance - this handles all of the cases where the dictionary had two or more slightly different versions of the utterance keys paired with a single value. It also handles all of the typical speakOs (do,due; to,two,too,2 etc.)

2) check the dictionary - the dictionary is drastically reduced because all of the C keywords are handled directly by 3…

3) parse the utterance for (almost) all reserved words (the dictionary still has a few which are typically used in isolation). Do some preliminary error checking (there are a few mutually exclusive reserved words - you may not have a variable of type "short string" etc.) Craft a statement placing the keywords in the proper order. Create a variable name built out of all of the words in the utterance which were not keywords.

With the exception of one very complex statement (building an enumerator block - which is almost working) I have tested this fairly thoroughly. My hot tub is almost full and is calling me - when I get out I will post some code…



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

-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

 02/19/2021 06:35 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

Originally posted by: kkkwj [in your video you suggested invoking the dictionary value cases as methods]

I used to know how to do this with Amiga C (using the Lattice C compiler). I finally found something online which showed me how to do it…

using System;
using System.Reflection;
using System.Windows.Forms;

namespace StatementConstructors {
   public partial class Program {
      private static void InvokeVoidMethod(string pValue) {
         Type type = typeof(SnippetFunctions);
         //SnippetFunctions snippetFunctions = (SnippetFunctions)Activator.CreateInstance(type);
         MethodInfo method = type.GetMethod(pValue);
         method.Invoke(null, null);
         //method.Invoke(snippetFunctions, null);

         //Since all of the possible methods are "static" the two commented-out lines are unnecessary
      }

      public class SnippetFunctions {
         public static void CompoundElse() {
            SendKeys.SendWait("else {{}{ENTER}{}}{UP}{END}");
         }

         public static void SimpleElse() {
            SendKeys.SendWait("else{ENTER}");
         }
[… There are quite a few additional methods]
      }
   }
}



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

-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



 02/19/2021 07:18 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

Here's a second look…

The attached zip is a complete solution. This version still uses the slow "what can I say" dialog. Although the Visualizer dialog class remains in the Project for now, it is no longer used. I also commented out the forced leading space (I rely on Visual Studio to clean up spurious spaces and odd formatting). If you find that it fails to insert a leading space when necessary just un-comment the line at or near line number sixty-one of Program.cs.

The Project has a text file in it ("TextFile1.TXT") which I am using as a testbed into which I can dictate.

I programmed all day yesterday using this application to deposit code snippets - probably 80% or more of the code I generated yesterday. Dragon®, KnowBrainer and Visual Studio ran continuously for over nine hours before Dragon crashed. Until today that was a record shattering continuous run. Today all three have been running for over eleven hours and I have not had one Dragon® crash! This has involved an incredible amount of coding almost all using this application to create the code.

Tomorrow I shall start dealing with the slow "what can I say" dialog (although, since we down to about 200 entries, on my system it's fast enough not to worry about it).

I got little time before I need to start dinner so I might try to create a demo video…






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

-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

 02/19/2021 07:24 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

kkkwj suggested a minor change to the Dragon® command:

Sub Main

   ShellExecute "Z:\StatementConstrucor\StatementConstructors.exe " & ListVar1, 7

End Sub

ShellExecute now has an additional parameter: ", 7"

It seems to be the reason why I was able to take out the Visualizer dialog.



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

-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

 02/19/2021 07:49 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

Okay, here's a quick video on YouTube…
https://youtu.be/YQt8eu_umfg



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

-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

 02/20/2021 10:13 AM
User is offline View Users Profile Print this message

Author Icon
lifeisgood
Top-Tier Member

Posts: 881
Joined: 06/29/2013

Like I commented in the video on YT, "I do not program, but this is AWESOME!
 02/20/2021 10:40 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

Originally posted by: lifeisgood Like I commented in the video on YT, "I do not program, but this is AWESOME!

@lifeisgood - thank you very much! 

A few of us have been batting around the concept of using an outside programming language to take some of the weight off of Dragon®. The concept is not restricted to programming! Virtually anything that can be done in a Dragon® or KnowBrainer script can be done in a compiled language like C# or a compiled Basic program. There are tremendous advantages in speed and parsing accuracy when you pass all the work off to a compiled application. As an added advantage debugging is far easier <grin>!



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

-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

 02/22/2021 08:02 AM
User is offline View Users Profile Print this message

Author Icon
LexiconCode
Senior Member

Posts: 82
Joined: 08/10/2018

Something I thought would be useful would to be hooking into language servers Via Language Server protocol.
https://langserver.org/

That way we can expose auto complete, go to definition, find all Eccentric references

 

My goal is to minimize the need to actually specify specifics especially for navigation.

Commands like next function

Next arg

And so forth...

 



 02/22/2021 11:00 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

Originally posted by: LexiconCode  Language Server protocol


I had never heard of this, but googled it just now. Will have to delve deeper…



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

-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

 02/22/2021 12:49 PM
User is offline View Users Profile Print this message

Author Icon
LexiconCode
Senior Member

Posts: 82
Joined: 08/10/2018

My skill set is in Python not so much C++/C# so I have not been able to pursue these concepts as far as I would like. Another tactic which could be complementary or replace the functionality Language Server protocol would be to leverage Microsoft accessibility UI automation.

For a long time I wanted to simply replace dragons Select-and-Say functionality because it's limited and very buggy. Not only that but it's limited to just Dragon versus many other speech recognition engines out there that I currently support in Caster.
https://docs.microsoft.com/en-us/dotnet/framework/ui-automation/ui-automation-overview

Using that we would need a few things:
For edit controls and grab editable text.
Absolute and relative carot position within the control
Watch for changes in the control to update

If we can grab the text directly from editor we can then use an incremental parser like tree-sitter to tokenized code for creating commands.
https://github.com/tree-sitter/tree-sitter


Me and a few other peoples have a limited version implemented without tree-sitter via Scintilla for notepad++ and SciTE. If you choose to pursue either of these let me know perhaps we can coordinate on Github perhaps Python bindings could be made as that's what most of the extended speech recognition community uses for grammars/rules.



 02/22/2021 03:26 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

Originally posted by: LexiconCode  perhaps Python bindings could be made as that's what most of the extended speech recognition community uses for grammars/rules.

Interesting. Last summer I showed a very preliminary version of this (no AI/parsing) to a highly skilled professional programmer. His comment was something along the lines of "Boy, if you could teach it to do Python it could be very popular."

I do not do Python unless I absolutely, positively must. Too many years writing in C-like languages I guess. The statement (and especially compound statements) structure of Python makes my head hurt! It's all in what you are used to.



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

-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

 02/23/2021 07:23 PM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 801
Joined: 11/05/2015

For my two bits, the LSP server is a great idea. I don't think we usually get such deep ideas on this forum. :-) The LSP protocol really reminds me of Stallman's old SUPDUP (superdooper?) protocol from back in 1978. The problem back then was that all editing had to be done on the mainframes, which was slow, and very slow over 300 baud communication lines. When semi-intelligent terminals came in that could do a form of local editing that could update the local display quickly (like "kill to end of line"), the problem became one of synchronizing the local display with the mainframe editor. That's exactly what the LSP server seems to be doing with its "EXTRAEXTRASUPDUP" JSON protocol. "I made this local change, now you update your copy."

But to take advantage of the protocol and language server, you need to be working with the editor or text control itself. Of course, this is basically a nonstarter with the Visual Studio editor because it's very difficult for an external program to get access to the object model for a VS buffer through COM.

In contrast, the simple approach that Edgar has posted here and that I helped to enhance in a small way is just a means for generating strings to send into your current editor with SendKeys statements. I've been making postings talking about how the experts do things, and I concluded that all of us experts (if I can include myself in that class) end up passing our commands outside of Dragon into external code to accomplish the goals that we need to accomplish.

Edgar and someone else (PG?) were the first ones to post examples of the simple basic scripts they were already using to generate programming statements into the Visual Studio editor. Edgar lifted up the game considerably with his first C# posting, which I lifted a little bit more with my tweaking to clean up the code and make the 17-second "what can I say" code faster (150ms).

Now Edgar has significantly expanded and improved his original version again (with some of my implementation suggestions and tweaks) and has posted what I consider to be more or less a state-of-the-art version of the tool for C#. I say state-of-the-art because I have never seen anything for voice that is equivalent, although perhaps some people in the dragonfly/caster/natlink community have equivalent tools for Python.

 

I don't know about such tools because (although I have posted on the Gitter channel a couple of times to ask questions), but am not familiar with the capabilities of the Dragonfly/Unimacro/Caster tools.

If it helps any, there is nothing at all complex about the code that Edgar has written. It just takes a voice utterance, looks it up in a hash table (previously, a long if/else statement), gets the assoicated output string, and emits the appropriate keystrokes. It could very easily be adapted to Python; dare I say it would even be trivial. The most arcane piece of code in the whole program is calling a function when you have the string name of the function in hand. This is an old, old technique that I first learned about in the mid/late 1970s, so I'm sure that python can do it.

 

Edgar has posted his code as open source, so go for it! With the talent that you have in the Python community, you could easily have a version up and running in a few days of effort. And it has nothing at all to do with complex grammars - just grab the utterance from Dragon based on an initial prefix keyword, pass the rest of the line to the code, and emit keystrokes.


I was really happy to see Edgar post his first, very simplistic basic script for doing this sort of thing. The reason is because the very first attempt breaks the ice and gets the ball rolling. Going from 0 to 1 is huge. Going from one to two to three to five is less challenging, especially if you are getting benefits from each version.



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

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, 3 BenQ 2560x1440 monitors, Microsoft Sculpt Keyboard and fat mouse



 02/23/2021 08:47 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

I have spent the last few days injecting this application with steroids! It now handles virtually all C/C++/C# keywords and reserved words. It intelligently builds things like classes, functions/methods, enumerators, structures etc. it has a section which parses the utterance for homophones and a couple of special other things. It has two sections devoted to generating output: the first section generates (often somewhat complicated) snippets based on looking up the utterance in a dictionary - requires an exact match but generally order is not important (private static is equal to static private); the second section is the real workhorse - it parses any utterance that does not fit the dictionary and builds (potentially incredibly complex) statements or partial statements. I have the documentation finished and that 17 second "What Can I Say" dialog opens virtually instantly and (because the code is not single-instance) it can stay open while you continue using the application. The user can dynamically control the font used in laying out this dialog. Tomorrow I hope to have time to publish the code and even make another video.

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

-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

 02/23/2021 08:51 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

The most incredible thing - I've been using it to work on itself, in three days of hard programming (at least 36 hours total) with Dragon®, KnowBrainer and Visual Studio all running continuously, I have only had Dragon® crash one time! For me this is a game changer. Using Dragon® to dictate directly into Visual Studio crashes at least twice an hour.

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

-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

 02/23/2021 10:12 PM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 801
Joined: 11/05/2015

Hi Edgar, I noticed in your code that you seem to be pasting the clipboard inside the parentheses of if-statements, like so:

public static void IfThisSimple() {
SendKeys.SendWait("if {(}{)}{LEFT}");
SendKeys.SendWait("^v");
SendKeys.SendWait("{RIGHT}{ENTER}");
}

Is that because you already have something on the clipboard that you want inside the condition parentheses? Do you treat that as an optional thing, or should people always make sure their clipboard is empty before invoking the if statement code? Maybe you could explain what's going on, and why? Thank you

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

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, 3 BenQ 2560x1440 monitors, Microsoft Sculpt Keyboard and fat mouse

 02/24/2021 11:15 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

Originally posted by: kkkwj I noticed in your code that you seem to be pasting the clipboard inside the parentheses of if-statements […] Is that because you already have something on the clipboard that you want inside the condition parentheses? Do you treat that as an optional thing, or should people always make sure their clipboard is empty before invoking the if statement code? Maybe you could explain what's going on, and why? Thank you

Good catch - brings up an omission in the documentation (which no one has seen). I will add something along this line…

Some of the dictionary entries have "this" as part of the utterance ("if this", "do while this" etc.). For these constructs, the contents of the clipboard is pasted in the appropriate place ("if (clipboard)", "do { } while (clipboard)" etc.). If there is no text on the clipboard nothing will be pasted - no harm no foul. It is the user's responsibility to make sure that the textual content of the clipboard is appropriate.



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

-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

 02/24/2021 11:30 AM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 801
Joined: 11/05/2015

Thanks, Edgar; does this mean you intend to write up and post a little documentation for the program? (There's no doc in the code... :-)). BTW you had a really nice idea to pull in stuff from the clipboard. In my design, I had allowed such "extra" information to be stored in external places (like the clipboard or files or whatever) and pulled in by name (although I never thought of using the word "this" to be a name for the clipboard.) I look forward to your doc (and probably the next upgrade to your program to study.

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

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, 3 BenQ 2560x1440 monitors, Microsoft Sculpt Keyboard and fat mouse

 02/24/2021 02:03 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

In re. documentation… The "What Can I Say" dialog has a small read-only TextBox on top which displays the documentation. That documentation is loaded from a text file included with the application (WhatYouCanSay.TXT). The attachment is that text file.






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

-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

 02/24/2021 03:06 PM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 801
Joined: 11/05/2015

Thanks, Edgar. The documentation file helped a lot. I didn't try the WCIS dialog and so didn't see the text file. This current program is a LONG way from your first small Basic version - well done!

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

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, 3 BenQ 2560x1440 monitors, Microsoft Sculpt Keyboard and fat mouse

 02/24/2021 06:00 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

I would call this a release candidate. I have attached StatementConstructors version 1.0.0.3 as a zip of the entire solution. The application will be looking for its documentation file (WhatYouCanSay.txt) in the application’s directory. I run a post-build event script which does this automatically on my system but would need to be modified to accommodate your file system (see StatementConstructorSuccessfulCompile.bat).

For a very brief period of time the wrong file was linked - while messing about with the "this" directions in the previous post I had turned that feature off - it's back on now and the attached file should work 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



 02/24/2021 09:19 PM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 801
Joined: 11/05/2015

Sorry to say, but the WYCS.txt file is nowhere to be found in the zip file. The TextFile1.txt entry is also missing. UPDATE: I thought about it overnight and realized that the WYCS.txt might not be part of the VS project (which was where I was looking). This morning I checked and sure enough, the file was present but not part of the project. The TextFile1.txt was part of the project, but was not part of the zip file. (Maybe you renamed it WhatCanYouSay.txt.)

 

And for some reason this version immediately backspaces a couple of times on a blank line before it emits the output text. Naturally, the backspacing destroys the CRLF at the front of my current line and joins lines that shouldn't be joined. Any hope of removing the initial backspacing? I looked over the code to see if I could find anything obvious or the line that said, "First, delete a few characters" but I failed. :-) 



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

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, 3 BenQ 2560x1440 monitors, Microsoft Sculpt Keyboard and fat mouse



 02/25/2021 11:11 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

Originally posted by: kkkwj the WYCS.txt might not be part of the VS project […] The TextFile1.txt was part of the project, but was not part of the zip file.

 

And for some reason this version immediately backspaces a couple of times on a blank line before it emits the output text. Naturally, the backspacing destroys the CRLF at the front of my current line and joins lines that shouldn't be joined. Any hope of removing the initial backspacing? I looked over the code to see if I could find anything obvious or the line that said, "First, delete a few characters" but I failed. :-)



You are partially correct about the text files. The "what you can.TXT" file is not part of the project - I had not thought to make it so (though I often drag-and-drop to open it in VS even though it is very difficult to edit there - I have not figured out how to turn on word wrap). As for TextFile1.TXT that was the file that I was using to test all of the dictionary methods and, as it was so large, I just deleted it as unnecessary. I must have forgotten to remove it from the project.

As for the backspacing - it should not be doing so; that might be a remnant of my having briefly posted the wrong file. Try downloading the current version (1.0.0.3) again (I have attached it to this post). The code in question is at the very bottom of MassageInput.cs:

      private static void GetLeading() {

         string selection = string.Empty, firstLeading = string.Empty, holdClipboard = Clipboard.GetText();


         Clipboard.Clear();

         SendKeys.SendWait("^c");

         selection = Clipboard.GetText();

         if (selection.Length != 0)

            SendKeys.SendWait("{Delete}");

         SendKeys.SendWait("+{LEFT}");

         SendKeys.SendWait("^c");

         firstLeading = Clipboard.GetText();

         if (firstLeading.Contains(Environment.NewLine) || string.IsNullOrEmpty(firstLeading)) {

            SendKeys.SendWait("{RIGHT}{UP}{END}{DOWN}");

            Clipboard.SetText(holdClipboard);

            return;//accept the defaults - at the beginning of a line

         }

         if (firstLeading != " ") //Immediately preceded by a character

            proceededByCharacter = true;

         else if ((firstLeading == "}") || (firstLeading == ";")) {

            proceededByCharacter = true;//Add a space after the statement termination

            SendKeys.SendWait("{END}");

            if (!injection) {

               proceededByCharacter = false;//Override the previous true

               SendKeys.SendWait("{ENTER}");

            }

         }

         Clipboard.SetText(holdClipboard);

      }

 

   }

It inspects the character immediately to the left of the insertion point to help decide whether to start with a leading space or just let IntelliSense figure out the proper indentation.

To the best of my knowledge the only place I actually delete any existing content is if there is currently a selection. If so, I am assuming that you want to type over that selection.






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

-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

 02/26/2021 10:23 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

Originally posted by: Edgar
Originally posted by: kkkwj  for some reason this version immediately backspaces a couple of times on a blank line before it emits the output text. Naturally, the backspacing destroys the CRLF at the front of my current line and joins lines that shouldn't be joined.

To the best of my knowledge the only place I actually delete any existing content is if there is currently a selection. If so, I am assuming that you want to type over that selection.

It turns out that there were two problems in the function I just posted. One was a subtle logic error in this area:

        if (firstLeading != " ") //Immediately preceded by a character
            proceededByCharacter = true;
         else if ((firstLeading == "}") || (firstLeading == ";")) {
            proceededByCharacter = true;//Add a space after the statement termination
            SendKeys.SendWait("{END}");
            if (!injection) {
               proceededByCharacter = false;//Override the previous true
               SendKeys.SendWait("{ENTER}");
            }

that became:

         if (firstLeading == " ") //not immediately preceded by a character
            proceededByCharacter = false;
         else if ((firstLeading == "}") || (firstLeading == ";")) {
            proceededByCharacter = true;//Add a space after the statement termination
            MessageBox.Show("End of statement", "DEBUG TITLE", MessageBoxButtons.OK, MessageBoxIcon.Error);
            SendKeys.SendWait("{END}");
            if (!injection) {
               proceededByCharacter = false;//Override the previous true
               SendKeys.SendWait("{ENTER}");
            }
         }
         else
            proceededByCharacter = true;

Subtle difference, but it seems to help.

The other problem is causing me serious loss of sleep. I'm ready to call it a bug/strange-feature in Visual Studio. I tend to do most of my initial bug testing in Notepad or PSPad so did not really see this bug very often. I did find a way to reliably and repeatably trigger the bug in Visual Studio so was able to track it down.

It turns out that if you HAVE a selection in most/all text editors AND press CTRL+c (the ubiquitous copy keyboard short command) the selection will be copied to the clipboard and my code:
         Clipboard.Clear();
         SendKeys.SendWait("^c");
         selection = Clipboard.GetText();
         if (selection.Length != 0)
            SendKeys.SendWait("{Delete}");
does the right thing by deleting the selection so that the generated snippet will be typed in its place. However, if you do NOT have a selection AND press CTRL+c… In every other text editor I have tried the result will be NOTHING copied to the clipboard (makes sense, nothing is selected so nothing is copied). In Visual Studio the unexpected result is that the entire line is copied to the clipboard. There must be a way to tell if Visual Studio has text selected - probably something like getting the RichTextBox control of the active window (conditionally, only if the active window is a Visual Studio window).

Originally, I assumed that I could just SendKeys over the selected text replacing the selection but that also did not work with Visual Studio.



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

-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

 02/26/2021 01:34 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

Originally posted by: EdgarI assumed that I could just SendKeys over the selected text replacing the selection but that also did not work with Visual Studio.


And, as it turns out, no other editors that I have tried. The application is working just fine now EXCEPT if there is a selection - that sound you just heard was me pulling my hair out.



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

-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

 02/26/2021 03:49 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

@Tar - you posted a link to a StackOverflow article which pretty well covers the whole "copy whole line if nothing is selected" situation. I thank you for that, at least now I know that I'm not crazy - well, I'm probably crazy, but not about that! BTW, your post disappeared <shrug>.



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

-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

 02/26/2021 03:56 PM
User is offline View Users Profile Print this message

Author Icon
tar
Junior Member

Posts: 26
Joined: 05/15/2019

Hello there, yes, I deleted the post because I saw that it did not really solve your problem after all. I had done a quick glance, and I thought it would help. I see the problem has been a long term situation with Visual Studio. I double checked on Visual Studio Code, and you have the same problem. I did a check with Ultraedit, with a better solution – no problem there. Anyway, I know that doesn't help with VS. Users have been complaining for years on this one. 



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

Tom


 


programmer for: http://speechproductivity.eu/

 02/26/2021 08:28 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

This might be the final version for a while! No new video, not much is changed visually. If you are playing along at home you might want to check the last paragraphs of this post.

New for version 1.0.0.4:

I fixed a bug involving the font in the "What Can I Say" dialog. Strings were being measured based on a immutable font not the Settings.Default.Font.

I made "internal" and "external" mutually exclusive. Just like "public" and "private" they may never be in the same statement.

I struggled trying to figure out how to replace selected text with the constructed output - I failed. If you have some text selected and you want to replace it you will have to say "press delete"Or your favorite equivalent.

There are a couple of new entries to the dictionary: "pound region", "end region", "size dot", "location dot", "not" or "exclamation mark" (logical not). Within the dictionary methods I noticed that in every place I had "else if" there was no space before the following opening parentheses - I added them.

You may now say: [trigger word, e.g. "puff"] followed by "pound region" and follow that with any utterance. The utterance will be parsed and made lowercase and the output will look something like:
#region a label for the region

You may now say: [trigger word, e.g. "puff"] followed by "camel case", "class case" or the equivalent "pascal case", "snake case", "pascal snake case" or the equivalent "snake pascal case", "upper case" or the equivalent "uppercase", "upper snake case" or the equivalent "snake upper case".

brownDog (camel case)
BrownDog (class or Pascal case)
brown_dog (snake case)
Brown_Dog (Pascal snake case)
BROWNDOG (upper case)
BROWN_DOG (upper snake case)

There is new a construction: for each [variable type] (e.g. "for each string", "for each float", "for each text box"). It tries to do the right thing with the variable type and the variable name:

foreach (string phrase in whatList ) {
}

foreach (float number in whatList ) {
}

foreach (TextBox textBox in whatList ) {
}

Since "string" is kind of special it uses the name "word". For numeric variable types it uses the generic name "number". For any other variable type it creates a Pascal-case type Followed by the same word with its initial character in lowercase.

There is a new special mode: "normalize line". If you have Visual Studio set so that it formats a line on paste or when a semicolon is pressed, this command will select the line and let IntelliSense cleanup the formatting.

SendKeys.SendWait() is known to have some timing issues. Microsoft® changed the default behavior a while back but left it possible for the developer to compile using the original behavior. There is a change which may be made in "App.config". I am including two versions: "App.config" and "App.bak.config". Look at the area around line number eleven to see the difference - try them both and see which works faster on your system.

New for version 1.0.0.5 (not yet released)

I am now using the other "App.config", this one has the addition of:
    <appSettings>
        <add key="SendKeys" value="SendInput"/>
    </appSettings>
it seems to be quite a bit faster and, assuming it continues working well for me it will be the default.






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

-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

 03/21/2021 07:53 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

 

New for version 1.0.0.5

I did a clean install of Windows 10 going from version 1804 to 20H2. Thereafter I installed Visual Studio 2019 and am now using it exclusively.

 

I am now using the other "App.config", this one has the addition of:

    <appSettings>

        <add key="SendKeys" value="SendInput"/>

    </appSettings>

it seems to be generally faster and, assuming it continues working well for me it will be the default.

 

I have added a few new snippets:

puff string format (string.Format)

 

puff environment line new (Environment.NewLine) - it would be more ergonomic to say "puff environment new line" but Dragon® chokes on "new line".

 

puff equals new (given "Point point" this constructs "Point point = new Point ();)

 

I think I now have all the "if then" constructors handled - there were some missing

In the process I also normalize all of the dictionary entries and massaged all (hopefully) of the possible permutations so that you may say things like (preface by your choice of command trigger word, e.g. puff):

"if simple else simple" or "if else" the word "simple" is redundant and unnecessary but allowed

"if this simple else" or "if simple this else simple" 

"if not this else"

"if not compound this else" or "if not this compound else" or "if compound not this else" or "if compound this not else"

The concept is you have the "if" part of the clause, then optionally an "else if" part of the clause then, again optionally, and "else" part of the clause. The "if" and "else if" part have some potential modifiers "simple" (the default and unnecessary to specify), "compound" (which has an alias: "complex"), "not" and "this" - the order in which you utter these modifiers does not matter. The "else" part (if specified) only has two possible modifiers: "simple" (again the default) and "compound" or its alias.

My Dragon® has a lot of trouble with the word "compound" when used in this manner; you may use the word "complex" in its place.

 

I added 4 specialized "if" constructions to the dictionary:

         {"if empty string", "IfStringEmpty"},// if (string.IsNullOrEmpty())

         {"if empty string this", "IfThisStringEmpty"},// if (string.IsNullOrEmpty(clipboard))

         {"if not empty string", "IfStringNotEmpty"},// if (!string.IsNullOrEmpty())

         {"if not empty string this", "IfThisStringNotEmpty"},// (!string.IsNullOrEmpty(clipboard))

and their "Compound" versions:

         {"if empty string compound", "IfStringEmptyCompound"}

         {"if empty string compound this", "IfThisStringEmptyCompound"}

         {"if not empty string compound", "IfStringNotEmptyCompound"}

         {"if not empty string compound this", "IfThisStringNotEmptyCompound"}

 

Added:

{"debug messagebox", "MessageBoxConstructorDebug"}

This one does the same as the generic MessageBox constructor but also adds "//DEBUG" to the end of the statement.

 

I have added a rule set for code analysis. It is the basic default with IDE0059 (unnecessary assignment of value to variable) turned off because I am in the habit of declaring almost all of my variables at the top of a method and assigning them reasonable default values at that time.

 

I have started adding the ability to define some built-in types. The utterance must start with the word "define":

Button, Point, Size, Label, Rectangle, string, TextBox, StringBuilder, Font

Look at the function "KnownCustomType" In the file "BuildAndSendVariables.cs", it should be pretty obvious how to add new types. You could say something like:

"puff define point" => Point point = new (, );

"puff define point some name" => Point someName = new (, );

Your text entry cursor will be positioned appropriately.






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

-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

 02/25/2021 11:41 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

FYI, StatementConstructor stores its settings here:

C:\Users\<USER>\AppData\Local\efm5

(where you replace <USER> with your username). You can also use:

%localappdata%\efm5

There will be at one or two (one each for Release and Debug versions) folders which start with:

StatementConstructor

(e.g. StatementConstructors.exe_Url_44htlqjmuep2zbsigdoy0aimwnk3qbud). There are only four settings: FirstDisplay; Location; Size; & Font. These are all related to the "What Can I Say" dialog.



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

-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

 02/25/2021 06:20 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

I just added two more videos for StatementConstructor to my YouTube channel (I say that so blithely - I've never posted a public video before these three). The "StatementConstructor1.0.0.3" video is a twenty-two minute video introducing the actual code and demonstrating how to use the StatementConstructor application. The "the What Can I Say dialog" video is about five minutes long and introduces the concept of keeping the "What Can I Say" dialog open while using the application to dictate snippets.


The "StatementConstructor1.0.0.3" video:

https://youtu.be/F-5jwuGHZdc


The "the What Can I Say dialog" video:

https://youtu.be/s_d1D66gCnI



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

-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



 03/23/2021 02:30 AM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 801
Joined: 11/05/2015

Hi Edgar, you've put in a lot of work to push your program forward. I watched the video and it's very powerful now. (Including that pesky bug that deleted my lines back in that first version long ago! :-) One of the things I liked the most was your use of your "Trim Front" command. I found an Edit.DeleteToBOL command in Vstudio but it kills to the BOL always instead of stopping at the indentation margin as your does. (Or as yours does most of the time; I saw it delete leftward more than once near the end of your video.) How did you implement the trim front command to stop at the left indentation margin like that?

From a design viewpoint, your program is the most powerful one that I know of. Everyone else who works with snippets uses a "one command + SendKeys" approach for each snippet, or a "command + database fetch + SendKeys/Clipboard" approach to deliver the snippet. And they don't "interact" with the utterance like your program does (swapping modifiers, checking for inconsistencies, etc.) The more I study the design of these tools and systems, the more I think there are two main approaches: 1) a stream-of-consciousness dictation and immediate/direct delivery by SendKeys approach, and a 2) "speak to load an app, choose a snippet, maybe edit it, and then deliver it" approach. The two approaches have such different characteristics that probably both approaches have their place in a complete toolkit.

Thank you for continuing to contribute to the expert thread with your constructor code!

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

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, 3 BenQ 2560x1440 monitors, Microsoft Sculpt Keyboard and fat mouse

 03/23/2021 11:45 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

Originally posted by: kkkwj  One of the things I liked the most was your use of your "Trim Front" command. I found an Edit.DeleteToBOL command in Vstudio but it kills to the BOL always instead of stopping at the indentation margin as your does. (Or as yours does most of the time; I saw it delete leftward more than once near the end of your video.)

I posted the code for "Trim Front" and "Trim Back" in the Dragon Macros section:

https://www.knowbrainer.com/forums/forum/messageview.cfm?catid=12&threadid=35533&enterthread=y

both of them are global and work reliably everywhere. Under Visual Studio, if you are in the middle of an indented line, if you say "Trim Front" Visual Studio always selects (and deletes) from the cursor to the first printable character (front of line, ignoring indentation); if you say it again it gets rid of all of the spaces of the indentation. I have smart tabs turned on and replace tabs with spaces turned on. I have never tested this with hard tabs.



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

-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

 03/23/2021 12:00 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

Originally posted by: kkkwj I think there are two main approaches: 1) a stream-of-consciousness dictation and immediate/direct delivery by SendKeys approach, and a 2) "speak to load an app, choose a snippet, maybe edit it, and then deliver it" approach. The two approaches have such different characteristics that probably both approaches have their place in a complete toolkit.

Lunis’ original set of "Code…" snippet constructors got me started on this. The first problem was that "code" was an impossible trigger word for me so I figured out how to edit the KnowBrainer XML commands file and changed all of the "Code…" commands to "Zotz…" commands. In the process I realized that many of those commands (few, if any, of which were list commands) could be compounded to reduce the command count. I did this for a lot of them and gave the code to Lunis - some of which he adopted.

I now have literally hundreds of "Zotz…" commands which create Verbal Basic code snippets. Realizing the power of the concept I decided to extend it to other programming languages (C++, HTML and a couple of other Basic-based languages). When I switched to C# and Visual Studio 2017 things started to fall apart because of IntelliSense. I decided to switch over to doing all the work in a C# compiled application, just using a single Dragon® global command (in a tribute to AG: "puff <dictation>").

I have a lot of the work completed for a "zotz <dictation>" compiled C# application which does for Basic in the same manner. It is a long way from ready for presentation!



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

-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

 03/23/2021 11:19 PM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 801
Joined: 11/05/2015

Hi Edgar, thank you for the instructed history of how you came to the place where you are at. I was thinking late last night (or early in the morning) after watching your latest video. I remember seeing a long list of "If utterance contains XYZ" statements in the Massage part of your program. 1) It seemed to me that you could replace that long list of if statements with another dictionary of match/replacement strings and then just use a small bit of looping code to apply each MassageDictionary item to the incoming utterance. 2) I could be wrong on this one, but assuming that all of your individual methods for emitting keystrokes just emit key sequences (versus doing if/else logic things), Then you could also get rid of all of those methods and just load the emitted keystrokes into the big dictionary. Then you could replace your dispatching code (key in, get name of emit method, invoke it) with Key-emitting code directly - instead of invoking a method to emit keys, just emit the keys themselves.

If you did these two replacements, your program code would probably be at least 1/3 smaller and easier to understand. Just a late-night thought.

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

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, 3 BenQ 2560x1440 monitors, Microsoft Sculpt Keyboard and fat mouse

 03/24/2021 12:49 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

Originally posted by: kkkwj versus doing if/else logic things

The code logic goes something like this: error check for nothing to process; (should probably error check for unwelcome punctuation also); normalize supplied utterance (it starts out as an array of one word strings, make everything lowercase and separated by a single space, trim any leading and/or trailing white space). This leaves an utterance which is ready to process. Next: see if the utterance matches any of a few "special" modes ("what can I say" etc.), if so process and exit; see if the utterance is in the dictionary (this requires an exact match), if so process and exit; otherwise, process the utterance to see if we can make any sense out of it.

This final process pulls the utterance apart and tries to create a sensible C# statement out of words that it recognizes as legitimately part of a C# statement. This is where most if not all of the "if contains" conditionals occur. Because sometimes when "if contains" is true multiple statements are executed (variable assignment, generally, not sending keypresses) I can't see how a Dictionary would suffice. This code is horribly convoluted with lots of if/else if/else and other conditionals. Much of this is involved with error checking (you can't proposed two different variable types in one utterance, 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

 03/24/2021 05:03 PM
User is offline View Users Profile Print this message

Author Icon
R. Wilke
Top-Tier Member

Posts: 7673
Joined: 03/04/2007

Admittedly, I don't have the time and the interest to read all of the above, but I just stumbled upon Kevin's recent reply and wondered whether he may have hit upon another case of a Coding Anti-Pattern this time, probably by chance. And that kind of pattern seems quite popular around here, given all the repeated if-then patterns showing up in scriptings posted to the forum, for no reason other than not knowing better.

To sum it up, by quoting from the page referred to above:

I bet these people hate going to the library to get a book by title, because it takes so darn long: They go up to the librarian and say, "Please give me all the books you have," and then they fill up their cart with thousands of books, then sit in the corner saying, "Nope, the title of this book is wrong. Nope, not that one either. Still the wrong title. How about this book? Nope, not this one either. Man, this is taking forever..."



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



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

DragonCapture KB Download (Latest)
DragonCapture Homepage



 03/28/2021 07:03 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

Sorry for the short turnaround time on version 1.0.0.7 - just before I published …6 I managed to introduce a spacing bug which only showed up in about one third of the snippets - ones I did not exercise before publishing. There's not a lot new here…

New for version 1.0.0.6

I exercised virtually all of the dictionary-based snippets in real-world code. Fixed a few problems.

 

I fixed a bug regarding spacing (or lack thereof) introduced in 1.0.0.5 (related to StringExtensions.NormalizeSpacing()).

 

I fixed a bug involving spurious carriage returns when a logical conditional immediately followed a right parenthesis.

 

I added new MessageBox constructors ("messagebox this" & "messagebox debug this").These put whatever is on the clipboard AS A VARIABLE in Naz the message.

 

I added the phrases "shell execute" & "shell execute constructor" to the dictionary. The first just types out the word "ShellExecute"; the second: ShellExecute "" & " " & ListVar1, 7

These properly belong in "Basic Statement Constructors" but I doubt that I will ever get around to finishing it <grin/frown>!






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

-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

 03/29/2021 11:59 AM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 801
Joined: 11/05/2015

Hi Edgar, thank you for the update! Did you manage to find "the pesky deletion bug" in this release? And your post mentions version 1.0.0.7, but the zip file says 1.0.0.6. Am I missing something?

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

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, 3 BenQ 2560x1440 monitors, Microsoft Sculpt Keyboard and fat mouse

 03/30/2021 07:08 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1187
Joined: 04/03/2009

Originally posted by: kkkwj Did you manage to find "the pesky deletion bug" in this release? And your post mentions version 1.0.0.7, but the zip file says 1.0.0.6. Am I missing something?

The "pesky deletion bug" is insurmountable. The problem is that Visual Studio will not allow dictating over a selected section - as soon as you start dictating over a selection it removes the selection (at least when doing so with SendKeys in C#).

1.0.0.6 is the last publicly released version (I'm currently working on …7, no bug fixes so far - just new features). I find …6 to be extremely stable and functional.



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

-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
32133 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 448 guests browsing this forum, which makes a total of 449 users using this forum.

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