开发者

How to set OPT programmatically with MS SAPI

Given the following which can be loaded into MS SAPI 5.1:

<GRAMMAR LANGID="409"> 
    <RULE NAME="top rule" TOPLEVEL="ACTIVE"> 
        <OPT>hello</OPT> 
        <P>my name is fred</P> 
    </RULE> 
</GRAMMAR>

How can I do the same programmatically, specifically with regard to the optional element.

I would guess it is done here:

state.AddWordTransition(nextState, "hello", " ", SpeechGrammarWordType.SGLexical,开发者_运维技巧 s, id, ref propValue, 1F);

...and it is probably the propValue. But what is the syntax (e.g, propValue="OPT=true" - does not work of course)

Thanks!


Optional words need an epsilon (empty) transition to the next state, so add:

state.AddWordTransition(nextState, NULL, NULL, SpeechGrammarWordType.SGLexical, s, id, ref propValue, 1F);

to add the epsilon transition.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜