I need create a programatic equivalent using delphi language... or could someone post a link on how to do grammars in peech recogniton using the delphi. sorry for my english...
**Programmatic Equivalent C#:**
Ref: http://msdn.microsoft.com/en-us/library/ms723634(v=VS.85).aspx
To add a phrase to a rule, SAPI provides an API called
ISpGrammarBuilder::AddWordTransition. The application developer can add
the sentences as follows:
SPSTATEHANDLE hsHelloWorld;
// Create new top-level rule called "HelloWorld"
hr = cpRecoGrammar->GetRule(L"HelloWorld", NULL,
SPRAF_TopLevel | SPRAF_Active, TRUE,
&hsHelloWorld);
// Check hr
// Add the command words "hello world"
// Note that the lexical delimiter is " ", a space character.
// By using a space delimiter, the entire phrase can be added
// in one method call
hr = cpRecoGrammar->AddWordTransition(hsHelloWorld, NULL,
L"hello world", L" ",
SPWT_LEXICAL, NULL, NULL);
// Check hr
// Add the command words "hiya there"
// Note that the lexical delimiter is "|", a pipe character.
// By using a pipe delimiter, the entire phrase can be added
// in one method call
hr = cpRecoGrammar->AddWordTransition(hsHelloWorld, NULL,
L"hiya|there", L"|",
SPWT_LEXICAL, NULL, NULL);
// Check hr
// save/commit changes
hr = cpRecoGrammar->Commit(NULL);
// Check hr
XML Grammar Sample(s):
<GRAMMAR>
<!-- Create a simple "hello world" rule -->
<RULE NAME="HelloWorld" TOPLEVEL="ACTIVE">
<P>hello world</P>
</RULE>
<!-- Create a more advanced "hello world" rule that changes the
display form. When the user says "hello world" the display
text will be "Hiya there!" -->
<RULE NAME="HelloWorld_Disp" TOPLEVEL="ACTIVE">
<P DISP="Hiya there!">hello world</P>
</RULE>
<!-- Create a rule that changes the pronunciation and the display
form of the phrase. When the user says "eh" the display
text will be "I don't understand?". Note the user didn't
say "huh". The pronunciation for "what" is specific to this
phrase tag and is not changed for the user or application
lexicon, or even other instances of "what" in the grammar -->
<RULE NAME="Question_Pron" TOPLEVEL="ACTIVE">
<P DISP="I don't understand" PRON="eh">what</P>
</RULE>
<!-- Create a rule demonstrating repetition -->
<!-- the rule will only be recognized if the user says "hey diddle
diddle" -->
<RULE NAME="NurseryRhyme" TOPLEVEL="ACTIVE">
<P>hey</P>
<P MIN="2" MAX="2">diddle</P>
</RULE>
<!-- Create a list with variable phrase weights -->
<!-- If the user says similar phrases, the recognizer will use
the weights to pick a match -->
<RULE NAME="UseWeights" TOPLEVEL="ACTIVE">
<LIST>
<!-- Note the higher likelihood that the user is
expected to say "recognizer speech" -->
<P WEIGHT=".95">recognize speech</P>
<P WEIGHT=".05">wreck a nice beach</P>
</LIST>
</RULE>
<!-- Create a phrase with an attached semantic property -->
<!-- Speaking "one two three" will return three different unique
semantic properties, with different names, and different
values -->
<RULE NAME="UseProps" TOPLEVEL="ACTIVE">
<!-- named property, without value -->
<P PROPNAME="NOVALUE">one</P>
<!-- named property, with numeric value -->
<P PROPNAME="NUMBER" VAL="2">two</P>
<!-- named property, with string value -->
<P PROPNAME="STRING" VALSTR="three">three</P>
</RULE>
</GRAMMAR>