KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: launching programatically accoustic optimiser
Topic Summary:
Created On: 08/25/2020 05:28 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 launching programatically accoustic optimiser   - dicdoc - 08/25/2020 05:28 PM  
 launching programatically accoustic optimiser   - PG LTU - 08/26/2020 01:34 PM  
 launching programatically accoustic optimiser   - dicdoc - 08/26/2020 04:58 PM  
 launching programatically accoustic optimiser   - dicdoc - 08/26/2020 06:11 PM  
 launching programatically accoustic optimiser   - Lunis Orcutt - 08/26/2020 07:22 PM  
 launching programatically accoustic optimiser   - PG LTU - 08/26/2020 07:10 PM  
Keyword
 08/25/2020 05:28 PM
User is offline View Users Profile Print this message

Author Icon
dicdoc
Top-Tier Member

Posts: 268
Joined: 07/31/2014

I found out this by error. I wanted to activate correction dialog (not menu), as with keyboard shorcut, but instead it launches accoustic optimiser. In case somebody needs it :

The parameter is dgndlgACODlg

Dim engine As New DgnEngineControl

Dim mic As New DgnMicBtn

mic.Register
mic.MicState = dgnmicSleeping
mic.UnRegister

'MsgBox (CSTR(ActiveWindowTitle))
'Stop
If InStr (CStr(ActiveWindowTitle), "Fenêtre d'épellation") Then
 SendKeys "%1",1
 GoTo FinCommune
End If
If InStr (CStr(ActiveWindowTitle), "Éditeur Dragon - ") Then
 SendKeys "{Pad-}",1
End If
If InStr (CStr(ActiveWindowTitle), " - Word") Then
 ButtonClick 1, 2
 SendKeys "{Pad-}",1
End If


DialogueCorrection:
  'Is the engine is ready to show the dialog ?
  ' AddWordDialog dgndlgACODlg
  If engine.DlgStatusGet(DgnDialogConstants.dgndlgACODlg) = DgnDlgStatusConstants.dgndlgstatusOK Then
      engine.DlgShow(DgnDialogConstants.dgndlgACODlg, n, , 0)'
  End If

FinCommune:
mic.Register
mic.MicState = dgnmicOn
mic.UnRegister

The reason why I want to activate it programatically, is that in certain situation, the sendkeys shorcut adds an unwanted lag


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

Memory: 16GB Microphone Brand and Model: LFH 4000 & Flexy Mike  Operating System: win 10, latest update; Surface Book 2, Processor (CPU) Type & Speed: I7 8650 Soundcard Brand and Model: none Speech Software: Dragon Medical Practice Edition, french version: 4.2 Using KnowBrainer?:Yes

 08/26/2020 01:34 PM
User is online View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2072
Joined: 03/21/2007

Hi dicdoc, pardon my interfering. But a few comments.

Why register a new 'DgnMicBtn' just to put the mic to sleep? Dragon Advanced Scripting ("DAS") includes the 'GoToSleep' and 'WakeUp' commands which can be used with the running instance:
https://www.nuance.com/products/help/dragon/dragon-for-pc/scriptref/Content/scrptref/gotosleep.htm
https://www.nuance.com/products/help/dragon/dragon-for-pc/scriptref/Content/scrptref/wakeup.htm

And then there is the 'SetMicrophone [onOff]' command for turning the mic on and off:
https://www.nuance.com/products/help/dragon/dragon-for-pc/scriptref/Content/scrptref/setmicrophone.htm

Then, for your ActiveWindowTitle options, you could simplify with 'ElseIf' construction:
https://www.nuance.com/products/help/dragon/dragon-for-pc/scriptref/Content/vbs/if_statement.htm

Finally, why are you creating a new DgnEngineControl object to interact with just to show a particular dialog? Presumably Dragon is already running if you are running this script! Just use the existing EngineControl (no need to Dim it). Here is a complete reference DAS implementation for showing a dialog using the Training Words dialog as an example:

'#Language "WWB-COM"
Option Explicit
Sub Main
    If (EngineControl.DlgStatusGet(dgndlgTrainWords)=dgndlgstatusOK) Then
        EngineControl.DlgShow(dgndlgTrainWords, 0, , 0)
    End If
End Sub

And no references or anything else needed.

 

But, as you noticed, there is no API access to the Correction Menu for the running Dragon engine.  You could use 'HeardWord "correct", "that"' but this only works if the mic is on.  What you want is shown in this reference implementation for calling the Correction Menu:

 

'#Language "WWB-COM"
Option Explicit
Sub Main
    EngineControl.RecognitionMimic("correct that")
End Sub

 

Hth,



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




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/26/2020 04:58 PM
User is offline View Users Profile Print this message

Author Icon
dicdoc
Top-Tier Member

Posts: 268
Joined: 07/31/2014

 

But, as you noticed, there is no API access to the Correction Menu for the running Dragon engine.  You could use 'HeardWord "correct", "that"' but this only works if the mic is on.  What you want is shown in this reference implementation for calling the Correction Menu:

 

 

 

'#Language "WWB-COM" Option Explicit Sub Main     EngineControl.RecognitionMimic("correct that") End Sub

 

 

 

Hth,

 

 

Thanks for your good advice Phil ! Which is fatser to launch betweeen EngineControl.RecognitionMimic("correct that")  and Sendkeys "correction shortcut" ?



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

Memory: 16GB Microphone Brand and Model: LFH 4000 & Flexy Mike  Operating System: win 10, latest update; Surface Book 2, Processor (CPU) Type & Speed: I7 8650 Soundcard Brand and Model: none Speech Software: Dragon Medical Practice Edition, french version: 4.2 Using KnowBrainer?:Yes

 08/26/2020 06:11 PM
User is offline View Users Profile Print this message

Author Icon
dicdoc
Top-Tier Member

Posts: 268
Joined: 07/31/2014

Originally posted by: PG LTU Hi dicdoc, pardon my interfering. But a few comments. Why register a new 'DgnMicBtn' just to put the mic to sleep? Dragon Advanced Scripting ("DAS") includes the 'GoToSleep' and 'WakeUp' commands which can be used with the running instance: https://www.nuance.com/products/help/dragon/dragon-for-pc/scriptref/Content/scrptref/gotosleep.htm https://www.nuance.com/products/help/dragon/dragon-for-pc/scriptref/Content/scrptref/wakeup.htm And then there is the 'SetMicrophone [onOff]' command for turning the mic on and off:

 

May be I miss sth: GoToSleep works fine, but WakeUp is not a recognoized command in KB

 



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

Memory: 16GB Microphone Brand and Model: LFH 4000 & Flexy Mike  Operating System: win 10, latest update; Surface Book 2, Processor (CPU) Type & Speed: I7 8650 Soundcard Brand and Model: none Speech Software: Dragon Medical Practice Edition, french version: 4.2 Using KnowBrainer?:Yes

 08/26/2020 07:22 PM
User is online View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 37984
Joined: 10/01/2006

DicDoc,

The Wakeup command can never be generated by any third-party utility because is it is exclusive to Dragon's limited collection of Asleep state commands which you can find at C:\ProgramData\Nuance\NaturallySpeaking15\Data\Enx\dvcu\general\system.dvc file.



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

Forum Mission Statement
Trial Downloads
Dragon/Sales@KnowBrainer.com 
(615) 884-4558 ext 1

 08/26/2020 07:10 PM
User is online View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2072
Joined: 03/21/2007

Yes, the SendKeys correction shortcut is another way. And what's nice is it works on keyboards without extended keyboards (so no dedicated NumPad keys). Or just pick any arbitrary one and set it at run time, resetting it when done...

Sub Main
  EngineControl.Option(dgnengoptionCorrectionHotKey)=262261 ' 262261 is Ctrl+F6
  SendKeys "^{F6}",1
  EngineControl.Option(dgnengoptionCorrectionHotKey)=0 ' 0 means blank, or restore with 109 for NumPad-
End Sub


As to WakeUp and KnowBrainer Scripting: wait for Lunis. Otherwise, just do it in Dragon Scripting.



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




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.



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

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