SAPI语音识别德尔福
-
27-09-2019 - |
题
我需要使用Delphi语言创建一个纲领性相当于...或可能有人张贴有关如何使用德尔福做语法在peech人识别的链接。或者说,在德尔福的方案相当于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>
解决方案 2
盖伊的我终于可以得到答案...... 点击 这可能是别人... :)搜索结果有用 这是我创建的实际组件。只是修改了您的需求。
Function TSRRule.AddWord (Word : String; Value : string = ''; Separator : char = '|') : integer;
var
OleValue : OleVariant;
begin
result := 0;
if Fwordlist.IndexOf(Word) = -1 then
begin
OleValue := Value;
Fwordlist.Add(Word);
FRule.InitialState.AddWordTransition(nil, word, Separator, SPWT_LEXICAL, FRuleName+'_value',Fwordlist.Count, OleValue, 1.0);
FWordCount := Fwordlist.Count;
result := FWordCount;
end;
end;
<强>调用函数... 强>结果
FSpRunTimeGrammar := SpInProcRecoContext.CreateGrammar(2); // we assign another grammr on index 2
SrRule1 := TSRRule.Create(1,'Rule1',FSpRunTimeGrammar);
with SrRule1 do
begin
AddWord('Maxtor');
AddWord('Open NotePad','Notepad.exe');
AddWord('Maxtor Dexter TrandPack','',' ');
commit;
end;
SrRule2 := TSRRule.Create(2,'Rule2',FSpRunTimeGrammar);
with SrRule1 do
begin
AddWord('the box');
AddWord('WeLcOmE SaPi');
AddWord('Halo World');
commit;
end;
FSpRunTimeGrammar.CmdSetRuleState('Rule1',SGDSActive);
FSpRunTimeGrammar.CmdSetRuleState('Rule2',SGDSActive);
请为澄清留下评语....好运气!
其他提示
有是绝地的团队所做的语音API直接包装,你应该能够从这里找到代码的 http://www.delphi-jedi.org/apilibrary.html 但我只是检查,并链接到sapi.zip文件似乎被打破,也许一个电子邮件绝地团队就能找到你。
如果你得到包装的保持,并给予这是API的直接包住,然后MDSN文档是你想要的,刚刚替补德尔福语法C ++语法的99%将是直线前进,这里面是不是有什么,只问的具体问题在这里(或在Embarcadero的新闻组)
不隶属于 StackOverflow