ahmet Posted May 24, 2016 Share Posted May 24, 2016 Hello, I am having problems using Microsoft Speech Platform. When I try to invoke DictationLoad and DictationSetState on Grammar object I get errors. expandcollapse popup#include <MsgBoxConstants.au3> Global Enum $SREStreamEnd = 1, $SRESoundStart = 2, $SRESoundEnd = 4, $SREPhraseStart = 8, $SRERecognition = 16, $SREHypothesis = 32, $SREBookmark = 64, _ $SREPropertyNumChange = 128, $SREPropertyStringChange = 256, $SREFalseRecognition = 512, $SREInterference = 1024, $SRERequestUI = 2048, _ $SREStateChange = 4096, $SREAdaptation = 8192, $SREStreamStart = 16384, $SRERecoOtherContext = 32768, $SREAudioLevel = 65536, $SREPrivate = 262144, _ $SREAllEvents = 393215 Global Enum $SRCS_Disabled = 0, $SRCS_Enabled = 1 ;SpeechGrammarState enumeration Global $SGSDisabled = 0, $SGSEnabled = 1, $SGSExclusive = 3 ;SpeechRuleState enumeration Global Enum $SGDSInactive = 0, $SGDSActive = 1, $SGDSActiveWithAutoPause = 3, $SGDSActiveUserDelimited = 4 Global Enum $SECLowConfidence = -1, $SECNormalConfidence = 0, $SECHighConfidence = 1 $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") $Recognizer=ObjCreate("Speech.SpInProcRecognizer") If Not IsObj($Recognizer) Then Exit MsgBox($MB_ICONERROR,"Error","Failed to initialize recognizer") $RecoContext=$Recognizer.CreateRecoContext() If Not IsObj($RecoContext) Then Exit MsgBox($MB_ICONERROR,"Error","Failed to initialize speech recognition") $Grammar = $RecoContext.CreateGrammar(1) If Not IsObj($RecoContext) Then Exit MsgBox($MB_ICONERROR,"Error","Failed to initialize grammar") _ConsoleWrite("GrammarState:" & $Grammar.State) $Grammar.DictationLoad() $Grammar.DictationSetState($SGDSActive) Func _ConsoleWrite($sText) Return ConsoleWrite($sText & @CRLF) EndFunc ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc Func Speech_Recognition($StreamNumber, $StreamPosition, $RecognitionType, $Result) $PhraseInfo=$Result.PhraseInfo _ConsoleWrite("LanguageID:" & $PhraseInfo.LanguageID) _ConsoleWrite("Text:" & $PhraseInfo.GetText) $Rule=$PhraseInfo.Rule ;childern, confidence, enngineconfidence, firstelement, id, name, numberofelements, parent _ConsoleWrite("Confidence:" & $Rule.Confidence) EndFunc Link to comment Share on other sites More sharing options...
falcontechnics Posted December 31, 2016 Share Posted December 31, 2016 (edited) Kimse cevap yazmamış... Ama zorlamak lazım. Translation: No one has written an answer ... But I need to force it. Edited December 31, 2016 by Melba23 Added translation Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now