Speech Recognition Grammar Rules using delphi code
Posted
by XBasic3000
on Stack Overflow
See other posts from Stack Overflow
or by XBasic3000
Published on 2010-05-14T01:38:15Z
Indexed on
2010/05/14
1:44 UTC
Read the original article
Hit count: 872
I need help to make ISeechRecoGrammar without using xml format. Like creating it on runtime on delphi.
example:
procedure TForm1.FormCreate(Sender: TObject);
var
AfterCmdState: ISpeechGrammarRuleState;
temp : OleVariant;
Grammar: ISpeechRecoGrammar;
PropertiesRule: ISpeechGrammarRule;
ItemRule: ISpeechGrammarRule;
TopLevelRule: ISpeechGrammarRule;
begin
SpSharedRecoContext.EventInterests := SREAllEvents;
Grammar := SpSharedRecoContext.CreateGrammar(m_GrammarId);
TopLevelRule := Grammar.Rules.Add('TopLevelRule', SRATopLevel Or SRADynamic, 1);
PropertiesRule := Grammar.Rules.Add('PropertiesRule', SRADynamic, 2);
ItemRule := Grammar.Rules.Add('ItemRule', SRADynamic, 3);
AfterCmdState := TopLevelRule.AddState;
TopLevelRule.InitialState.AddWordTransition(AfterCmdState, 'test', temp, temp, '****', 0, temp, temp);
Grammar.Rules.Commit;
Grammar.CmdSetRuleState('TopLevelRule', SGDSActive);
end;
can someone reconstruct or midify this delphi code (above) to be exactly same function below(xml).
<GRAMMAR LANGID="409">
<!-- "Constant" definitions -->
<DEFINE>
<ID NAME="RID_start" VAL="1"/>
<ID NAME="PID_action" VAL="2"/>
<ID NAME="PID_actionvalue" VAL="3"/>
</DEFINE>
<!-- Rule definitions -->
<RULE NAME="start" ID="RID_start" TOPLEVEL="ACTIVE">
<P>i am</P>
<RULEREF NAME="action" PROPNAME="action" PROPID="PID_action" />
<O>OK</O>
</RULE>
<RULE NAME="action">
<L PROPNAME="actionvalue" PROPID="PID_actionvalue">
<P VAL="1">albert</P>
<P VAL="2">francis</P>
<P VAL="3">alex</P>
</L>
</RULE>
</GRAMMAR>
sorry for my english...
© Stack Overflow or respective owner