Sign in to follow this  
Followers 0
Champak

Voice control problems

2 posts in this topic

#1 ·  Posted (edited)

I'm having some problems with voice command. It doesn't seem to be consistent. It seems it is because the audio stream wont close after a certain amount of calls which wildly varies. Sometimes it happens after 3 calls, sometimes it happens after 20 calls, generally no more than 11. Can someone tell me what's wrong....or better yet, how to force the audio stream closed.

I've put a lot of event captures in this example so it is easy to see what is happening.

#include "GUIConstants.au3"

Global $oVoiceCommand = ObjCreate("SAPI.SpSharedRecoContext")
Global $oVoiceGrammer = $oVoiceCommand.CreateGrammar(1)
$oVoiceGrammer.Dictationload
Global $oSpeak = ObjCreate("SAPI.SpVoice")
ObjEvent($oVoiceCommand,"VCEvent_")


GUICreate ("VC Tester", 140, 80 )
    $Button = GUICtrlCreateButton("Click and Speak", 10, 10, 100, 25)
GUISetState ()


While 1
    $msg = GUIGetMsg()
        Select
            Case $msg = $Button
                Speak()
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
        EndSelect
Wend

Func Speak()
    
    $oSpeak.Speak("  Please say a command. ")
    $oVoiceGrammer.DictationSetState(1)  
    sleep(7000)  
    $oVoiceGrammer.DictationSetState(0)
    ConsoleWrite("! Dictation End" & @CRLF)
    Run(@ComSpec & "  /c echo " & Chr(7), "" , @SW_HIDE)
EndFunc

Func VCEvent_Interference($StreamNumber,$StreamPosition,$StreamInterference)
    ConsoleWrite("! Interference" & @CRLF)
    ConsoleWrite("-------------------------" & @CRLF & @CRLF)
EndFunc

Func VCEvent_StartStream($StreamNumber,$StreamPosition)
    ConsoleWrite("+ Stream Start" & @CRLF)
    ConsoleWrite("+ " & $StreamNumber & @CRLF)
    ConsoleWrite("-------------------------" & @CRLF & @CRLF)
EndFunc

Func VCEvent_SoundStart($StreamNumber,$StreamPosition)
    ConsoleWrite("+ Sound Start" & @CRLF)
    ConsoleWrite("-------------------------" & @CRLF & @CRLF)
EndFunc

Func VCEvent_PhraseStart($StreamNumber,$StreamPosition)
    ConsoleWrite("+ Phrase Start" & @CRLF)
    ConsoleWrite("-------------------------" & @CRLF & @CRLF)
EndFunc

Func VCEvent_Recognition($StreamNumber,$StreamPosition,$RecognitionType,$Result)
    ConsoleWrite("> Voice Command Recognized: " & $Result.PhraseInfo.GetText & @CRLF & @CRLF)
    ConsoleWrite("-------------------------" & @CRLF & @CRLF)
EndFunc

Func VCEvent_SoundEnd($StreamNumber,$StreamPosition)
    ConsoleWrite("! Sound End" & @CRLF)
    ConsoleWrite("-------------------------" & @CRLF & @CRLF)
EndFunc

Func VCEvent_EndStream($StreamNumber,$StreamPosition,$StreamReleased)
    ConsoleWrite("! Stream End" & @CRLF)
    ConsoleWrite("! " & $StreamNumber & @CRLF)
    ConsoleWrite("-------------------------" & @CRLF & @CRLF & ">>>>>>>>>>>>>>>>>>>>>>>>>" & @CRLF & @CRLF)
EndFunc


#cs
Func VCEvent_RecognitionForOtherContext($StreamNumber,$StreamPosition)
    ConsoleWrite("> Recognition For Other Context" & @CRLF)
    ConsoleWrite(">  " & $StreamNumber & @CRLF)
    ConsoleWrite(">  " & $StreamPosition & @CRLF)
    ConsoleWrite("-------------------------" & @CRLF & @CRLF)
EndFunc
#ce
#cs
Func VCEvent_Hypothesis($StreamNumber,$StreamPosition,$Result)
    GUICtrlSetData ( $GUIEdit, "Hypothized text is: " & $Result.PhraseInfo.GetText & @CRLF  , "append" )
    ConsoleWrite("+ Hypothesised" & @CRLF)
    ConsoleWrite("+  " & $StreamNumber & @CRLF)
    ConsoleWrite("+  " & $StreamPosition & @CRLF)
    ConsoleWrite("+  " & $Result & @CRLF)
    ConsoleWrite("-------------------------" & @CRLF & @CRLF)
    ;$oSpeak.Speak($Result.PhraseInfo.GetText & " activated.")
EndFunc
#ce
;#cs
Func VCEvent_FalseRecognition($StreamNumber,$StreamPosition,$Result)
    ConsoleWrite("! False Recognition" & @CRLF)
    ConsoleWrite("-------------------------" & @CRLF & @CRLF)
EndFunc
;#ce
Edited by Champak

Share this post


Link to post
Share on other sites



bump

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0