我需要创建一个使用delphi语言编程的等价物......或者有人可以发布关于如何使用delphi语言识别语法的链接。或者在Delphi中具有相同编程等级的XML语法的任何示例。对不起我的英语不好。SAPI语音识别delphi
**Programmatic Equivalent **
编号:http://msdn.microsoft.com/en-us/library/ms723634(v=VS.85).aspx
SPSTATEHANDLE hsHelloWorld;
hr = cpRecoGrammar->GetRule(L"HelloWorld", NULL,
SPRAF_TopLevel | SPRAF_Active, TRUE,
&hsHelloWorld);
hr = cpRecoGrammar->AddWordTransition(hsHelloWorld, NULL,
L"hello world", L" ",
SPWT_LEXICAL, NULL, NULL);
hr = cpRecoGrammar->AddWordTransition(hsHelloWorld, NULL,
L"hiya|there", L"|",
SPWT_LEXICAL, NULL, NULL);
hr = cpRecoGrammar->Commit(NULL);
XML语法样品(S):
<GRAMMAR>
<!-- Create a simple "hello world" rule -->
<RULE NAME="HelloWorld" TOPLEVEL="ACTIVE">
<P>hello world</P>
</RULE>
<RULE NAME="HelloWorld_Disp" TOPLEVEL="ACTIVE">
<P DISP="Hiya there!">hello world</P>
</RULE>
<RULE NAME="Question_Pron" TOPLEVEL="ACTIVE">
<P DISP="I don't understand" PRON="eh">what</P>
</RULE>
<RULE NAME="NurseryRhyme" TOPLEVEL="ACTIVE">
<P>hey</P>
<P MIN="2" MAX="2">diddle</P>
</RULE>
<RULE NAME="UseWeights" TOPLEVEL="ACTIVE">
<LIST>
<P WEIGHT=".95">recognize speech</P>
<P WEIGHT=".05">wreck a nice beach</P>
</LIST>
</RULE>
<RULE NAME="UseProps" TOPLEVEL="ACTIVE">
<P PROPNAME="NOVALUE">one</P>
<P PROPNAME="NUMBER" VAL="2">two</P>
<P PROPNAME="STRING" VALSTR="three">three</P>
</RULE>
</GRAMMAR>
感谢蒂姆先生!我试图替换所有参数。它没有错误。但是两者有不同的结果。我想知道'L'是如何在参数中做的。 {GetRule(L“HelloWorld”....)}我没有把它包含在我的参数中。这是否意味着一个列表? – XBasic3000 2010-05-17 02:51:57
L“Hello World”表示“Hello World”是一个“宽”(或Unicode)字符串。 – 2010-05-17 23:33:39
是的,埃里克的权利。 – 2010-05-18 00:15:50