Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help using SAPI ISpGrammarBuilder's "::AddWordTransition"

58 views
Skip to first unread message

Mosquito@discussions.microsoft.com Danny Mosquito

unread,
Jul 13, 2009, 3:43:02 AM7/13/09
to
HI....

I am currently using the MS SAPI5.3 libs in a c++ application and would like
to know how to add an Optional phrase programatically using the
ISpGrammarBuilder's "::AddWordTransition". I have been able to successfully
add a standard phrase programatically from the example off msdn using
ISpGrammarBuilder::AddWordTransition see xml below.

hr = g_cpCmdGrammar->AddWordTransition(hRule, NULL, L"Something to Replace
Placeholder", L"", SPWT_LEXICAL, NULL, NULL);

<RULE ID="VID_ARTICLE" DYNAMIC="TRUE">

<P>Placeholder</P>

</RULE>

This works fine however I would also like to be able to add an Optional
(Opt) phrase at run time like you would see in the grammar xml below.

<RULE ID="VID_ARTICLE" DYNAMIC="TRUE">

<P>Placeholder</P>

<O>Optional Placeholder</O>

</RULE>

Anyone have any ideas how I add the optional tag using the grammar builder?

Danny Mosquito

unread,
Jul 13, 2009, 6:45:01 AM7/13/09
to
Very sorry it seems I made my post in haste. The answer was in MSDN right in
front of my face the whole time.. Hope I didn't waste anyones time - see link
below if you need to know the answer:
http://msdn.microsoft.com/en-us/library/ms723634(VS.85).aspx

// Add the optional command word "world"
hr = cpRecoGrammar->AddWordTransition(hInterim, NULL,
L"hello", NULL,SPWT_LEXICAL, NULL, NULL);
// Check hr

// Add the epsilon transition, which means no word need be spoken
hr = cpRecoGrammar->AddWordTransition(hInterim, NULL,NULL, NULL,
SPWT_LEXICAL, NULL, NULL);

Umaid

unread,
Jul 28, 2009, 5:22:01 AM7/28/09
to
I am also adding this word transition via xml, so can you please help me,
that how this is possible in VB.Net

--------------------------------------------------------------------------

0 new messages