KnowBrainer Speech Recognition
Decrease font size
Increase font size
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
Linear : Threading : Single : Branch
 HeardWord with <dictation>   - Edgar - 08/11/2021 10:52 AM  
 HeardWord with <dictation>   - Alan Cantor - 08/11/2021 12:44 PM  
 HeardWord with <dictation>   - Edgar - 08/11/2021 02:37 PM  
 HeardWord with <dictation>   - PG LTU - 08/12/2021 10:18 AM  
 HeardWord with <dictation>   - Edgar - 08/12/2021 12:27 PM  
 HeardWord with <dictation>   - Alan Cantor - 08/12/2021 01:26 PM  
 HeardWord with <dictation>   - Edgar - 08/12/2021 03:14 PM  
 HeardWord with <dictation>   - wristofdoom - 08/24/2021 01:19 PM  
 HeardWord with <dictation>   - monkey8 - 08/12/2021 03:36 PM  
 HeardWord with <dictation>   - Edgar - 08/12/2021 03:44 PM  
 HeardWord with <dictation>   - monkey8 - 08/12/2021 03:52 PM  
 HeardWord with <dictation>   - monkey8 - 08/12/2021 05:00 PM  
 HeardWord with <dictation>   - PG LTU - 08/12/2021 05:22 PM  
 HeardWord with <dictation>   - monkey8 - 08/14/2021 11:28 AM  
 HeardWord with <dictation>   - Edgar - 08/12/2021 07:21 PM  
 HeardWord with <dictation>   - Edgar - 08/14/2021 03:14 PM  
 HeardWord with <dictation>   - Mav - 08/24/2021 03:07 AM  
 HeardWord with <dictation>   - Edgar - 08/24/2021 10:53 AM  
 HeardWord with <dictation>   - Mav - 08/25/2021 04:02 AM  
 HeardWord with <dictation>   - Edgar - 08/24/2021 02:42 PM  
 HeardWord with <dictation>   - wristofdoom - 08/24/2021 07:26 PM  
Keyword
 08/11/2021 10:52 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1396
Joined: 04/03/2009

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.

I cannot figure out how to write a script which accomplishes "Strikethrough|Strikeout <dictation>". I've tried the obvious:

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
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 & Shokz OpenComm UC version 1 wireless headset, 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

 08/11/2021 12:44 PM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4615
Joined: 12/08/2007

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.

 08/11/2021 02:37 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1396
Joined: 04/03/2009

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

I wonder if EmulateRecognition would work around this restriction?



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

-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 & Shokz OpenComm UC version 1 wireless headset, 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

 08/12/2021 10:18 AM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2272
Joined: 03/21/2007

Originally posted by: 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.



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




PG





Remember folks, my comments and this forum are for entertainment value only, please, no wagering or other reliance on the contents herein.  I permit no commercial use of my ideas (whether expressions or embodiments) without my written consent.

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

Author Icon
Edgar
Top-Tier Member

Posts: 1396
Joined: 04/03/2009

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
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 & Shokz OpenComm UC version 1 wireless headset, 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

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


Alan Cantor
Top-Tier Member

Posts: 4615
Joined: 12/08/2007

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

 08/12/2021 03:14 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1396
Joined: 04/03/2009

@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

Even if I make the delay much longer than 3 seconds (3 seconds would be intolerable anyway) the Select Case code processes before the selection is made. I can see the result of the ‘SendKeys "^s", 1’ statement briefly (the Strikethrough icon toggles for three seconds). It would appear that the ‘
EngControl.RecognitionMimic is not exercised until the command exits.



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

-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 & Shokz OpenComm UC version 1 wireless headset, 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

 08/24/2021 01:19 PM
User is offline View Users Profile Print this message

Author Icon
wristofdoom
Top-Tier Member

Posts: 347
Joined: 09/03/2020

Originally posted by: Alan Cantor 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 Sub Main Dim x As String Let x = ListVar1 Dim EngControl As New DgnEngineControl EngControl.Register EngControl.RecognitionMimic (x) EngControl.UnRegister (False) End Sub

 

 

 

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.

 08/12/2021 03:36 PM
User is offline View Users Profile Print this message

Author Icon
monkey8
Top-Tier Member

Posts: 4186
Joined: 01/14/2008

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.  


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



 08/12/2021 03:44 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1396
Joined: 04/03/2009

@monkey8 - your version will not compile on my system (15.3).



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

-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 & Shokz OpenComm UC version 1 wireless headset, 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

 08/12/2021 03:52 PM
User is offline View Users Profile Print this message

Author Icon
monkey8
Top-Tier Member

Posts: 4186
Joined: 01/14/2008

Interesting, it does with 15.61, I forget the numbers already but isn't 15.3 SAX Basic instead of WinWrap. Have you removed the option explicit and entered the script exactly as shown?  Also in what application does SendKeys "%s" change the selection to strike through?



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



 08/12/2021 05:00 PM
User is offline View Users Profile Print this message

Author Icon
monkey8
Top-Tier Member

Posts: 4186
Joined: 01/14/2008

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. 

 

EmulateRecognition is a function I added to kb, It is not available under Advanced Scripting from Dragon.



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

 08/12/2021 05:22 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2272
Joined: 03/21/2007

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.



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




PG





Remember folks, my comments and this forum are for entertainment value only, please, no wagering or other reliance on the contents herein.  I permit no commercial use of my ideas (whether expressions or embodiments) without my written consent.



 08/14/2021 11:28 AM
User is offline View Users Profile Print this message

Author Icon
monkey8
Top-Tier Member

Posts: 4186
Joined: 01/14/2008

Originally posted by: PG LTU … 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. 

 

 

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.

 



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



 08/12/2021 07:21 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1396
Joined: 04/03/2009

I'm going to try farming this off to a C# application.

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

-Edgar
DPI 15.3, 64-bit Windows 10 Pro, OpenOffice & Office 365, Norton Security, Shure X2U XLR to USB mic adapter with Audio Technica DB135 vocal mic & Shokz OpenComm UC version 1 wireless headset, 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

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

Author Icon
Edgar
Top-Tier Member

Posts: 1396
Joined: 04/03/2009

Farming it out to C# solve the problem for me.

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

-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 & Shokz OpenComm UC version 1 wireless headset, 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

 08/24/2021 03:07 AM
User is offline View Users Profile Print this message

Author Icon
Mav
Top-Tier Member

Posts: 723
Joined: 10/02/2008

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> I think we'd need a separate variable apart from <dictation>, but I don't think that this <xyz> can be used inside a command.

mav

 08/24/2021 10:53 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1396
Joined: 04/03/2009

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
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 & Shokz OpenComm UC version 1 wireless headset, 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

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

Author Icon
Mav
Top-Tier Member

Posts: 723
Joined: 10/02/2008

Originally posted by: Edgar 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.

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

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

Author Icon
Edgar
Top-Tier Member

Posts: 1396
Joined: 04/03/2009

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
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 & Shokz OpenComm UC version 1 wireless headset, 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

 08/24/2021 07:26 PM
User is offline View Users Profile Print this message

Author Icon
wristofdoom
Top-Tier Member

Posts: 347
Joined: 09/03/2020

Originally posted by: Edgar 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.

 

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.


I tried the same command in Microsoft Word, and got the same result that I got in Notepad: Rather than selecting the uttered text that already existed on the page, it simply typed the other text, as though the command was nothing more than `SendKeys ListVar1`

 

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.

Statistics
32616 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 212 guests browsing this forum, which makes a total of 213 users using this forum.

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