SAPI语音识别delphi
我需要使用delphi语言创建一个等价的编程...或者有人可以发布一个关于如何使用delphi在语音识别中进行语法的链接。或者任何在 Delphi 中具有编程等效性的 XML 语法示例。对不起我的英语。
**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 语法示例:
<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>
I to need create a programmatic equivalent using delphi language... or could someone post a link on how to do grammars in peech recogniton using the delphi. Or any examples of XML grammar that has programmatic equivalent in Delphi. sorry for my english.
**Programmatic Equivalent **
Ref: 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 Grammar Sample(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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
jedi 团队有一个针对语音 api 的直接包装器,您应该能够从这里找到代码 http://www.delphi-jedi.org/apilibrary.html 但是我刚刚检查过,sapi.zip 文件的链接似乎已损坏,也许发送给 jedi 团队的电子邮件会将其打开为你准备。
如果你确实掌握了包装器,并且考虑到这是 API 的直接包装,那么 MDSN 文档就是你想要的,只需将 Delphi 语法替换为 C++ 语法 99% 将是直接的,如果不是,只需询问具体问题请参见此处(或 Embarcadero 新闻组)
There is a direct wrapper for the speech api done by the jedi team, you should be able to find the code from here http://www.delphi-jedi.org/apilibrary.html however I just checked and the link to the sapi.zip file seems to be broken, perhaps an email to the jedi team will turn it up for you.
If you do get hold of the wrapper, and given this is direct wrap of the API, then the MDSN docs are what you want, just substitute Delphi syntax for C++ syntax 99% will be straight forward, that which isn't, just ask the specific question in here (or on the Embarcadero newsgroups)
我终于得到答案了......
这可能对其他人有用...:)
这是我创建的实际组件。只需根据您的需要修改它即可。
调用函数...
请发表评论以供说明...祝您好运!
Guy's I finally able to get the Answer ....
This might be useful to others... :)
this is the actual component that i created. just modify it for your needs.
Calling function...
Please Leave comment for clarifications.... good luck!