Jump to content

SAPI 5.1 - Unknow bug


Recommended Posts

Hello,

I'm using code from post.

$oRecoContext = ObjCreate('SAPI.SpSharedRecoContext')
If @error Then
    MsgBox(0, '', 'Object Creation Failed')
    Exit
EndIf

ConsoleWrite('You can speak now' & @CRLF)
ObjEvent($oRecoContext, 'RecoContext_')

Global $oVBS = ObjCreate("ScriptControl")
$oVBS.Language = "VBScript"
Global Const $oNothing = $oVBS.Eval("Nothing")

$oGrammar = $oRecoContext.CreateGrammar()

$oTopRule = $oGrammar.Rules.Add('RUN', 1, 0)
$oWordsRule = $oGrammar.Rules.Add('WORDS', BitOR(1, 32), 1)

$oAfterCmdState = $oTopRule.AddState()

$oTopRule.InitialState.AddWordTransition($oAfterCmdState, 'run')
$oAfterCmdState.AddRuleTransition($oNothing, $oWordsRule)

$oWordsRule.InitialState.AddWordTransition($oNothing, 'notepad')
;~ $oWordsRule.InitialState.AddWordTransition($oNothing, 'whatever')

$oGrammar.Rules.Commit()

$oGrammar.CmdSetRuleState('RUN', 1)


While 1
    Sleep(10)
WEnd


Func RecoContext_FalseRecognition($iStreamNumber, $vStreamPosition, $iResult)
    ConsoleWrite("(no recognition)" & @CRLF)
EndFunc   ;==>RecoContext_FalseRecognition

Func RecoContext_Recognition($iStreamNumber, $vStreamPosition, $iRecognitionType, $iResult)
    ConsoleWrite($iResult.PhraseInfo.GetText() & @CRLF)
    If $iResult.PhraseInfo.Elements.Item(1).DisplayText = 'notepad' Then
        Run('notepad.exe')
    EndIf
EndFunc   ;==>RecoContext_Recognition

You need: Microsoft Speech SDK 5.1

How it works?

When I speak 'run notepad' it recognizes voice and run notepad.exe. Everything works great... but only for some time. After ~ 2 minutes voice commands don't work!

Where is problem? (main loop works fine)

I'm waiting for your reply. Thanks for help! =)

/Adrian

Link to comment
Share on other sites

just curiosity i never use objects and SAPI before... how can i solve this?

F:\Agustin\autoit\Foro Autoit\sapi.au3 (11) : ==> Variable must be of type "Object".:
$oVBS.Language = "VBScript"
$oVBS^ ERROR

x64?

Run 32-bit AutoIt.

♡♡♡

.

eMyvnE

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...