Delphi Speech recognition delphi
Posted
by XBasic3000
on Stack Overflow
See other posts from Stack Overflow
or by XBasic3000
Published on 2010-05-17T01:28:03Z
Indexed on
2010/05/17
1:30 UTC
Read the original article
Hit count: 1442
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...
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>
**Programmatic Equivalent:**
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
© Stack Overflow or respective owner