KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: Is it possible to call dgnEngine from C# to have Dragon run a command?
Topic Summary: Kind of like running HeardWord from an external program
Created On: 01/03/2021 01:56 PM
Status: Post and Reply
Linear : Threading : Single : Branch
Keyword
 01/03/2021 01:56 PM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 703
Joined: 11/05/2015

Is is possible (and feasible) to call some Dragon API interface (like dgnEngine) to have it run a command in its command list? Does it do COM or do you have to link to it directly? I'm wondering if it is possible to write a simple DOS batch file something like this:

 

CallDragon "open command browser"

CallDragon "open microsoft word"

CallDragon "press backspace"

 

Or something like that. And the big question - does anyone have a small example program in any programming language that they are willing to share? (Every time I try to look at the hidden underlying documents beside the Dragon executables, I get scared and feel like I'm wasting time trying to figure out how to interact with the engine and its events...) 



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

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

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

Author Icon
Mphillipson
Top-Tier Member

Posts: 261
Joined: 09/22/2014

I've never gone down the Common Object Model interface route with C#, always just created Advanced or KnowBrainer scripts.

There is an alternative to using SendKeys with C# which is called the InputSimulator

For more information on how to install this and use it please see the following:

https://www.nuget.org/packages/InputSimulator/

This enables you to write code like the following with full IntelliSense support:

InputSimulator inputSimulator = new InputSimulator();
inputSimulator.Keyboard.KeyPress(VirtualKeyCode.BACK);



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

Thanks Mark


 


Dragon Professional Advanced Scripting/KnowBrainer Scripts
Video Examples of Coding by Voice



 01/03/2021 09:08 PM
User is offline View Users Profile Print this message

Author Icon
dilligence
Top-Tier Member

Posts: 1301
Joined: 08/16/2010

I think you're looking for ComObjCreate("Dragon.DgnEngineControl") to mimic Dragon recognition.

 

The basic idea is roughly the same in most languages like AHK, WinBatch, Quick Macros but also in VBS:

 

DgnEngine:= ComObjCreate("Dragon.DgnEngineControl")

DgnEngine.Register(0)

DgnEngine.RecognitionMimic("stop listening") 

 

In some languages you need to add Dgn.UnRegister as well.

 

Shouldn't be too hard to implement in C#.



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



 01/03/2021 11:10 PM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 703
Joined: 11/05/2015

Thank you everyone, your input has helped. I already do input simulation with the virtual key codes (which is not the same as trying to harness the library of "things" that a user's library of commands can do. Rob, the COM example you posted is right on the money too - that's exactly how you do it in C# code (syntax is a bit different, of course). There are many examples on the net. Probably the key line of code that answered my question was the "DgnEngine.RecognitionMimic("text") line. (Thank you for reminding me, Rob.) I remember reading about the Create, DgnEngine.Register, mimic, Unregister sequence on the forum somewhere long ago, now that I see it in front of me.


I know some other people on the forum here have a regular practice of using external programs (like DragonEmulate or whatever) to feed commands into Dragon to make it think it "HeardWord" something. It must be a useful practice since they do it, so I was just thinking about it. I think Edgar passes dictation to Dragon to his program (to process the words) and then back to Dragon to get a functionality boost. If any one makes huge use of this pattern, I wonder if you would comment on the big benefits of the approach?


I was just contemplating what benefits I could imagine if I did something like that, and posted here just to find out how easy it would be. (Easy, it looks like.) It's almost like you could treat Dragon as an intelligent "non-voice assistant for a natural-language scripting language." Just put your almost-natural-language "commands" in a text file and feed the file to Dragon as a scripting engine. Presto! Easier than learning a programming language, I suppose. :-)



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

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

 01/04/2021 05:54 AM
User is offline View Users Profile Print this message

Author Icon
Mphillipson
Top-Tier Member

Posts: 261
Joined: 09/22/2014

Regarding how to pass information from Dragon to a C# application, please see the YouTube video at:

https://youtu.be/uUWUUD8T9qQ 152

The Browse Scripts Application is available on Github at the following location:

https://github.com/Mark-Phillipson/SpeechRecognitionHelpers/tree/master/BrowseScripts



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

Thanks Mark


 


Dragon Professional Advanced Scripting/KnowBrainer Scripts
Video Examples of Coding by Voice



 01/04/2021 10:45 AM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 703
Joined: 11/05/2015

Hi Mark, wow, your video was nice. I think that's the best video of yours that I have watched. It makes me want to learn and practice how easily you move around Visual Studio by voice, and to put grid stickers on my monitor to facilitate the movement. And thank you for putting your code up on Github too - your command browser looks very helpful. I wish I had more time to study and learn more from you and Edgar. But there are only 24 hours in a day (sigh). Happy New Year!

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

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

 01/04/2021 12:08 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1112
Joined: 04/03/2009

Originally posted by: kkkwj   that's exactly how you do it in C# code (syntax is a bit different, of course).

Post (or link to) some code, please. I too have the same reaction to learning how to tame the Dragon®.



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

-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

 01/04/2021 02:59 PM
User is offline View Users Profile Print this message

Author Icon
R. Wilke
Top-Tier Member

Posts: 7509
Joined: 03/04/2007

Originally posted by: Edgar
Originally posted by: kkkwj   that's exactly how you do it in C# code (syntax is a bit different, of course).

 

Post (or link to) some code, please. I too have the same reaction to learning how to tame the Dragon®.

 

Edgar, and everyone else posting to this thread: Stop wasting your time even thinking of it.



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



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

DragonCapture KB Download (Latest)
DragonCapture Homepage

 01/04/2021 04:30 PM
User is offline View Users Profile Print this message

Author Icon
monkey8
Top-Tier Member

Posts: 3727
Joined: 01/14/2008

Hi Kevin,

 

I think this is what you are asking for. I have attached a C# executable compiled from a C# project which took 30 minutes to produce using components supplied with a standard Dragon installation, DPI or DPG and visual studio 17. The application will explain itself when you run it but basically it shows you Dragon voice commands added into your application and it also demonstrates utilising existing Dragon voice commands in your application using the Dragon API, the application of course need not have a window. You will notice that calling an existing dragon command is instant unlike using heardword or recognitionMimic with scripting. You could always disassemble it to see how it's done or use our consultancy which is available for companies wanting to do this sort of thing. 

 

You don't do it the way that has been described above in the relevant posts but it can be done as you can see when you run the executable. Let me know if it doesn't run for some reason.

 

Lindsay

 

EDIT: to download the zip file you need to right click on it and then choose "save Link as". I have also digitally signed the latest attachment to save you getting various warning screens when you try to run the unzipped executable.. You will however get a warning about downloading a zip file from KnowBrainer which you can ignore.

 






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



 01/04/2021 06:34 PM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 703
Joined: 11/05/2015

Hi Lindsay, thank you for the convincing demo! It was flawless. I put it in the background by clicking on File Explorer (and/or Word), and the "show image 1/2" commands still went to the demo app, even though the demo app was not foreground. I suppose that's because those commands were global and know how to contact the demo app to do something. Most impressive, for sure. It goes way beyond what I was contemplating. I'll send you a PM about consulting.

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

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

 01/04/2021 07:12 PM
User is offline View Users Profile Print this message

Author Icon
dilligence
Top-Tier Member

Posts: 1301
Joined: 08/16/2010

Works flawlessly indeed. Lindsay still rules ;-)

 

Thanks Mark for the tip on C# Input Simulator. I will check that out for sure.



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

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

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