![]() |
KnowBrainer Speech Recognition | ![]() |
Topic Title: Activating WSRMacro voice commands via Keyboard Shortcut Topic Summary: Does anyone have coding for using a .vbs to EmulateRecognition a WSRMacro? Created On: 06/28/2020 03:00 PM Status: Post and Reply |
|
![]() |
![]() |
- NiptheZephyr | - 06/28/2020 03:00 PM |
![]() |
![]() |
- NiptheZephyr | - 06/28/2020 03:01 PM |
![]() |
![]() |
- Ag | - 06/28/2020 05:15 PM |
![]() |
![]() |
- NiptheZephyr | - 06/28/2020 05:30 PM |
![]() |
![]() |
- Lunis Orcutt | - 08/08/2020 04:59 PM |
![]() |
![]() |
- Mav | - 07/02/2020 03:05 AM |
![]() |
![]() |
- NiptheZephyr | - 07/25/2020 07:52 PM |
![]() |
![]() |
- Tiger Feet | - 08/08/2020 11:21 AM |
![]() |
|
TL;DR
My goal is to run a .vbs file with code that will send a text string to WSR to be recognized as speech input. I know it's a bass-ackwards thing to do, but I'm trying to play around w/ WSRMacros in my freetime at home, and looking for a quiet/silent way to test out my scripting without distracting my wife when we are talking or waking her up if it's late at night.
Full Story:
First off, I want to say that this is my frist post to the KnowBrainer forums, and I want to say thank you to everyone on here. I've been creeping on here for a few years, and have found the communities knowledgebase incredible, and everyone very helpful and friendly in their posts. Also, if there is a clearer way to post the below code in the forum, please let me know.
I started off using DNS Medical just for dictation a few years ago, got into it's advanced scripting to develop efficient macros for our old EMR, and then tried to find something similar to do for repetitive tasks at home. This past year I've picked up a bit of VBScript, using Notepad ++ to code and desktop shortcuts assigned to keyboard combinations to run it. I recently started to use WSR and WSRMacros to create similar, voice activated macros, but as I noted up in the TL;DR, I can't casually test my scripts without being rude to the people I'm around if we are just hanging out together, and so I wanted to pick your (know)brains. I'm trying to craft a vbscript that will use EmulateRecognition to send a string, interpreted as speech, to WSR/WSRMacros, so I can set it as a keyboard shortcut.
I know one can access the SAPI as an object to use it's methods, based upon the below:
Set Sapi = Wscript.CreateObject("sapi.SpVoice")
Based off of this link: https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms723609(v=vs.85)
It looks like there are a few more methods under SpVoice that one can call, but I'm not seeing those as any viable options for putting text as speech into the system. Higher up on the contents section on the left, it looks like SpVoice falls under the Automation heading. Looking through all the other Objects, the ISpeechRecognizer contains the method EmulateRecognition. ISpeechRecognizer is not described as an Object, but the coding higher on the page shows it being created as one. So, I tried the following:
Set Sapi = Wscript.CreateObject("SAPI.SpSharedRecognizer")
Which doesn't give me any errors, but won't activate the WSR to start listening. This site: https://www.autohotkey.com/boards/viewtopic.php?t=8389, states that it only runs within the application using the EmulateRecognition command, which in this case would be Notepad++. I've tried numerous other iterations, with the same result. I took them from the docs.microsoft.com corresponding pages and their code snippets. For example:
1. Set Sappy = Wscript.CreateObject("Sapi.SpSharedRecoContext")
I've tried confirming that the stuff is actually running with the below codes, but given my limited coding knowledge am unsure if it's actually checking the state, or I'm just setting a variable to be something that returns as true:
1. Set Sapi = Wscript.CreateObject("Sapi.SpSharedRecognizer")
2.Set Sapi = Wscript.CreateObject("Sapi.SpSharedRecognizer")
I also used Microsoft Office's VBA editor's Object Browser to try to find some other Objects/methods to try. My computer apparently has a SapiCS 1.0 Library in it's references, which appears to belong to the WSRMacros program, however trying to CreateObject those is a complete failure, with the following error:
"Could not locate automation class named "xxx"
Where xxx has been:
1. "SapiCS.CSpApplication" used with
Set Sapi = Wscript.CreateObject("SapiCS.CSpApplication")
Where SapiCS was the library and CSpApplication was the class.
2. "SapiCS.ISpRecognizer" used with
Set Sapi = Wscript.CreateObject("SapiCS.ISpRecognizer")
Where SapiCS was the library and ISpRecognizer was the class.
3. "SAPI.CSpApplication" used with
Set Sapi = Wscript.CreateObject("SAPI.CSpApplication")
Where SapiCS was the library and CSpApplication was the class, in my jenky version of playing around with the library.
So there you have it. It's broke me, I have to admit I've hit a wall, and has finally caused me to create an account to ask the forums instead of just searching through it for bits of knowledge. Any guidance anyone can provide would be much appreciated. If it's just "this is impossible", fair enough, but an explanation of why would be nice to help grow my knowledge base. Sorry for the incredibly long post, just wanted to walk you through what I've already explored.
V/r,
NiptheZephyr
|
|
|
|
![]() |
|
Gaa, sorry for the formatting, don't know why it knocked out all the returns.
|
|
|
|
![]() |
|
I find that in this web.forum I need to provide 2 newlines to get paragraphs properly separated by a blank line.
e.g. there is a completely blank "paragraph" between this paragraph and the previous
but between this paragraph and the next I will only do a single newline there is only a single newline, no blank paragraph, between this and the previous ------------------------- DPG15.6 (also DPI 15.3) + KB, Sennheiser MB Pro 1 UC ML, BTD 800 dongle, Windows 10 Pro, MS Surface Book 3, Intel Core i7-1065G7 CPU @ 1.3/1.5GHz (4 cores, 8 logical, GPU=NVIDIA Quadro RTX 3000 with Max-Q Design. |
|
|
|
![]() |
|
Thanks Ag,
Will use it from now on!
*Fixed the above formatting. |
|
|
|
![]() |
|
I find that in this web.forum I need to provide 2 newlines to get paragraphs properly separated by a blank line.
e.g. there is a completely blank "paragraph" between this paragraph and the previous
but between this paragraph and the next I will only do a single newline
there is only a single newline, no blank paragraph, between this and the previous
Tiger nailed it but you have an even faster solution: Place your cursor in the middle of your paragraph (to make it more difficult) and say Paragraph <this is special agent orange from the FBI>. This command will move your cursor to the end of the paragraph, press {Shift+Enter} twice (to create a real paragraph) and simultaneously type “this is special agent orange from the FBI”. Now you're cooking with jet fuel
------------------------- Forum Mission Statement |
|
|
|
![]() |
|
Hi! I've also tried invoking built-in commands of WSR (similar to what Dragon's "HeardWord" does), but to no avail. I think the problem is that you can only emulate recognitions for your own Recognizer instance. With WSR you can have many independent Recognizers, each with its own set of grammars. So far I haven't found a way to get to the "Desktop instance" grammars. Basically, you have 2 options with WSR: Create your own recognizer in-process or use the "shared" out-of-process recognizer. The first one can handle audio input independently for each instance. The second one shows the UI and automatically handles default audio from the microphone, but apart from that you also get your own instance without any Grammars. If you add a grammar to recognize "do something" and then call EmulateRecognition("do something"), then you'll get a recognized event from your own grammar, but that won't influence the instance running in the background. I just found another difference between the in-process and the "shared" engine: The in-process recognizer will fire SpeechRecognized events even for utterances colliding with built-in commands whereas the shared recognizer won't. Regards, mav |
|
|
|
![]() |
|
May,
Thanks for the info. Your info game me some things to play around with, but like you said, wasn't able to get it to work. I'm curious as to if creating one's own grammar, having some code activate WSRMacros, and then using an EmulateRecognition would do trigger any of the .WSRMacro files you have, but I myself don't understand what grammars are enough to do it. It was a wonderful exercise in learning code and concepts, but I ended up calling it quits. Switched to AutoHotKey, since it still allowed a way to send inputs to activate certain coding and use part of what I type as a variable in the text. Pretty much using a HotString to recognize a typed number to run a loop however many times I specify. Thanks again. |
|
|
|
![]() |
|
Ag, ------------------------- Tiger Feet |
|
|
FuseTalk Standard Edition v4.0 - © 1999-2021 FuseTalk™ Inc. All rights reserved.