![]() |
KnowBrainer Speech Recognition | ![]() |
Topic Title: HeardWord with <dictation> Topic Summary: How does one combine the two in a script Created On: 08/11/2021 10:52 AM Status: Post and Reply |
|
![]() |
![]() |
- Edgar | - 08/11/2021 10:52 AM |
![]() |
![]() |
- Alan Cantor | - 08/11/2021 12:44 PM |
![]() |
![]() |
- Edgar | - 08/11/2021 02:37 PM |
![]() |
![]() |
- PG LTU | - 08/12/2021 10:18 AM |
![]() |
![]() |
- Edgar | - 08/12/2021 12:27 PM |
![]() |
![]() |
- Alan Cantor | - 08/12/2021 01:26 PM |
![]() |
![]() |
- Edgar | - 08/12/2021 03:14 PM |
![]() |
![]() |
- wristofdoom | - 08/24/2021 01:19 PM |
![]() |
![]() |
- monkey8 | - 08/12/2021 03:36 PM |
![]() |
![]() |
- Edgar | - 08/12/2021 03:44 PM |
![]() |
![]() |
- monkey8 | - 08/12/2021 03:52 PM |
![]() |
![]() |
- monkey8 | - 08/12/2021 05:00 PM |
![]() |
![]() |
- PG LTU | - 08/12/2021 05:22 PM |
![]() |
![]() |
- monkey8 | - 08/14/2021 11:28 AM |
![]() |
![]() |
- Edgar | - 08/12/2021 07:21 PM |
![]() |
![]() |
- Edgar | - 08/14/2021 03:14 PM |
![]() |
![]() |
- Mav | - 08/24/2021 03:07 AM |
![]() |
![]() |
- Edgar | - 08/24/2021 10:53 AM |
![]() |
![]() |
- Mav | - 08/25/2021 04:02 AM |
![]() |
![]() |
- Edgar | - 08/24/2021 02:42 PM |
![]() |
![]() |
- wristofdoom | - 08/24/2021 07:26 PM |
![]() |
|
Imagine that I am dictating into a RichTextBox field. I utter "The quick brown fox jumped over the lazy dog". After a brief pause, I utter "bold quick brown". Dragon has some built-in command which recognizes this and just "does the right thing"; it has similar built-in commands for italicize and underline but not for strikethrough/strikeout. Sub Main Dim selection As String
selection = "select " & ListVar1 HeardWord selection Wait 0.4 SendKeys "%s", 1 End Sub
"%s" is the accelerator for the "Strikethrough" item. If I utter "press alternate Sierra" or do the same with the keyboard (after selecting something "somehow") the selection is struck through.
The real question here is, how do I "select <dictation>" from within an Advanced Scripting macro? ------------------------- -Edgar |
|
|
|
![]() |
|
I've never been able to figure out how to do this.
The closest I've come to a solution is this: Sub Main Dim x As String Let x = ListVar1 HeardWord "select", x End Sub But it only works when ListVar1 consists of exactly one word, one symbol, or a number between 0 and 99. It fails for multiple words. |
|
|
|
![]() |
|
That was my exact experience. I tested it on a single word - it worked fine. I sent it off to my beta tester who immediately tried it on three words and it failed. I have now played around with splitting up <dictation> - still no success: Sub Main Dim selection, another As String Dim words() As String' dimension a string array Dim dictation As String Dim k As Integer Dim result As String
selection = Chr(34) & "select" & Chr(34) & ", " dictation=ListVar2 words=Split(dictation," ") For k = 0 To UBound(words) selection = selection & Chr(34) & words(k) & Chr(34) & ", " Next selection = Mid(selection, 1, Len(selection) - 2) ' MsgBox selection' string is now built perfectly: ""select", "over", "the"" ' HeardWord selection' does not work another = "select over the" ' HeardWord another' does not work 'HeardWord "select", "over", "the" ' works just fine Wait 0.4 ' SendKeys "{Esc}", 1 Select Case ListVar1 ' […] Case "Strikethrough", "Strike Out", "Strikeout" SendKeys "%s", 1 End Select End Sub ------------------------- -Edgar |
|
|
|
![]() |
|
I wonder if EmulateRecognition would work around this restriction?
Yes, of course because it takes but a single string sequence that can include spaces and is easily accessible in the command browser without referencing or registering anything. So, using the dictation variable and some processing to come up with a string to "recognize" is a natural.
In fact, that was the first "real" reason I had to come up with pgEmulate as detailed more here because I was using AutoHotKey to recognize a command that then passed an utterance to the recognizer. So, if I said "Strikethrough|Strikeout something" I first send the "select something" to Dragon, and if that something is "that" it selects the last utterance like saying "select that" or else it has Dragon search the viewport for the "something" to select, and then apply the strikethrough|strikeout in your case or uppercasing, camelcasing, titlecasing, etc. I was implementing. -------------------------
|
|
|
|
![]() |
|
I cannot get even the simplest Advanced Scripting command to compile with EmulateRecognition: Sub Main EmulateRecognition "copy that" End Sub EmulateRecognition -> **ERROR** (10551) Expecting a constant, vulvar name or function name. It's like I might be missing a Reference but I have tried a shotgun approach of adding all of the dragon-related references without any success. BTW I am running DPI 15.3 but I cannot imagine that something this simple is broken in this version of Dragon. ------------------------- -Edgar |
|
|
|
![]() |
|
Edgar,
This seems to work in Version 15.61. I'm also able to include multi-word command names, e.g., "Testing bold hello through goodbye" Testing <dictation> Sub Main Dim x As String Let x = ListVar1 Dim EngControl As New DgnEngineControl EngControl.Register EngControl.RecognitionMimic (x) EngControl.UnRegister (False) End Sub |
|
|
|
![]() |
|
@Alan - your EngControl version works except… Sub Main Dim EngControl As New DgnEngineControl Dim x As String Let x = "select " & ListVar2 EngControl.Register EngControl.RecognitionMimic (x) EngControl.UnRegister (False) Wait 3 SendKeys "{Esc}", 1 Wait 0.5 Select Case ListVar1 Case "Normal", "Regular", "Regularize", "Normalize" SendKeys "^n", 1 Case "Strikethrough", "Strike Out", "Strikeout" SendKeys "^s", 1 End Select End Sub ------------------------- -Edgar |
|
|
|
![]() |
|
What is this supposed to do exactly? When I run this command in Notepad, it simply types the text that was uttered.
It's unclear to me how this could help to select and then modify some pre-existing text (by adding bold, etc) ------------------------- Dragon Professional Individual v15.6. Windows 10. Knowbrainer 2017. |
|
|
|
![]() |
|
No need to create and register an engine control to use recognitionMimic, no need to move data between variables.
Command Name e.g. "Testing <dictation>"
Sub Main EngineControl.RecognitionMimic (ListVar1) 'Wait and send your keys End Sub
If you're going to use HeardWord you need to break the listvar (dictation) into separate words as PG alludes to.
Edgar regarding the problem you are seeing use Dragon and not KB. KB currently runs the command on the COM Dragon recoognition
event handler, which is a single threaded apartment, synchronously and the COM WinWrap control(Another STA) has to wait for Dragon in very unique circumstances of which this is one
this causes the issue you are seeing. The issue will be fixed in the next release of KB.
------------------------- |
|
|
|
![]() |
|
@monkey8 - your version will not compile on my system (15.3). ------------------------- -Edgar |
|
|
|
![]() |
|
|
|
![]() |
|
Sub Main EmulateRecognition "copy that" End Sub EmulateRecognition -> **ERROR** (10551) Expecting a constant, vulvar name or function name.
EmulateRecognition is a function I added to kb, It is not available under Advanced Scripting from Dragon. ------------------------- |
|
|
|
![]() |
|
The other thing is (as Edgar guessed correctly) the emulation doesn't occur until the then-current script is done. No matter how long you wait, the sent keys cannot act on the thing the recognizer selects. You can call pgEmulate though, and that will run in a separate process once called, and if your script has been "waiting" around, and the focus hasn't been lost, those sent keys just might hit your target. -------------------------
|
|
|
|
![]() |
|
done. No matter how long you wait, the sent keys cannot act on the thing the recognizer selects.
Yes because of what I said above regarding STAs but I didn't realise it also did it with Dragon Advanced Scripting as well(I guess it would now that they are using WinWrap). The script will run okay with the next version of KB which will run the STA asynchronously so the recognitionMimic will be complete before the wait and thus the SendKeys will hit the target like your pgEmulate.
------------------------- |
|
|
|
![]() |
|
I'm going to try farming this off to a C# application.
------------------------- -Edgar |
|
|
|
![]() |
|
Farming it out to C# solve the problem for me.
------------------------- -Edgar |
|
|
|
![]() |
|
Out of curiosity: How does <dictation> behave in contrast to <xyz> (you know, like in "Select XYZ Command")? If you say "select <xyz>", this xyz has to be a substring of the current editor's text, otherwise the command will not fire. Dragon builds this selection grammar every time the contents of the editor have changed. <dictation>, in contrast, is an arbitrary sequence of words, not neccessarily those already in your target window. So in order to really achieve what you wanted in the beginning (strike through <xyz> mav |
|
|
|
![]() |
|
I suspect that they are, in fact, identical. If you utter "the quick brown fox", pause, then utter "select party" (i.e. in Notepad), DragonĀ® simply ignores the command. That's what my C# application does also.
------------------------- -Edgar |
|
|
|
![]() |
|
While I haven't tested those built-in commands with text outside the current scope, I'm still under the impression of what my German Dragon used to do when trying to use select-and-say in a not supported window: Saying "Markier <xyz>" always yielded "Marquis xyz". I interprete this as Dragon creating a selection grammar with the current text content (empty or just the previous utterance in case of an unsupported control) and if the utterance does not match this selection grammar, you get the result from the dictation grammar. Regards mav |
|
|
|
![]() |
|
Notepad is not a rich text editor so the specific command would not be of much help there. Think more along the lines of Word, WordPad or other rich text editors which allow strikethrough and bolding. DragonĀ® has built-in commands for bolding, italicizing and underlining (assuming the conventional keyboard shortcuts for each exist in the target application) but not for strikethrough nor normalizing (removing all formatting/styling).
Imagine the target application had keyboard shortcuts for things like "make the selected text's color various-popular-colors". We could create a command "Paint various-popular-colors dictation" which would select the phrase which was equal to "dictation" and change its text color to the specified color. The big challenge was to figure out how to accomplish: HeardWord "select ", dictation in the middle of an Advanced Script. It turns out that the solution was to pass that part of the job off to an external application so that the work was done before the script exited instead of after the script exited. ------------------------- -Edgar |
|
|
|
![]() |
|
I understand the solution you went for, which is probably completely beyond me.
However, it sounded like the command that I quoted was actually successful for mimicking the "select <dictation>" command that's built into Dragon – something that I would love to be able to mimic reliably.
However, Alan Cantor said that it worked for him. I thought maybe it would work for me because I'm on 15.6 ------------------------- Dragon Professional Individual v15.6. Windows 10. Knowbrainer 2017. |
|
|
FuseTalk Standard Edition v4.0 - © 1999-2023 FuseTalk™ Inc. All rights reserved.