Question SAPI grammar

SureshDeoda

New member
Joined
Oct 5, 2009
Messages
4
Programming Experience
1-3
Hi ,
I tried some tutorials with SAPI and now i am trying to build a command & control application .
It is working fine for some fixed commands, but i want to activate it for my login form where usernames are updatable ( means i have some command words which can change runtime).
So is there any way i can add those usernames from my database to grammar files so that i can let users call the username as commands.
As per this page, Exploring Speech Recognition And Synthesis APIs In Windows Vista
i can append the choices in the grammar , but its using Speech.recognition namespace ( and if i am not wrong earlier is COM method using SpeechLib ) , so can i use grammarbuiler and append choices in my existing grammar?? ( i tried but not working)
This is what is working initially ( here i hardcoded some usernames in the grammar file)

VB.NET:
Imports SpeechLib ' For Speech API object model


Public WithEvents RC As SpSharedRecoContext 'Create the RecoContext for the shared recognizer engine 

dim myGrammar As ISpeechRecoGrammar ' Declaring a grammar context for this form

 RC = New SpSharedRecoContext ' Initialise the Shared recognition context

        myGrammar = RC.CreateGrammar ' Initialise the myGrammar as grammar for the recoContext

        myGrammar.CmdLoadFromFile("D:\data\logGrammar1.xml", SpeechLoadOption.SLODynamic) 'load the Grammarfile

        myGrammar.CmdSetRuleIdState(0, SpeechRuleState.SGDSActive) ' activate the top level Grammar rule

now i tried to append those usernames in a grammarfile and no doubt its not working..

VB.NET:
Dim userNames As Choices

            userNames = New Choices("one", "two", "three", "four")

            Dim userNameGramBuilder As New GrammarBuilder

            userNameGramBuilder.Append(userNames)

            Dim myGrammar As Grammar

            myGrammar = RC.CreateGrammar ' Initialise the myGrammar as grammar for the recoContext

            myGrammar = New Grammar(userNameGramBuilder)

myGrammar.Enabled = True

Kindly guide me to find some solution.

Thanks ,
Suresh
 
Back
Top