Discussion:
Help using SAPI ISpGrammarBuilder's "::AddWordTransition"
(too old to reply)
Danny Mosquito
2009-07-13 07:43:02 UTC
Permalink
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
2009-07-13 10:45:01 UTC
Permalink
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);
Post by Danny Mosquito
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?
Umaid
2009-07-28 09:22:01 UTC
Permalink
I am also adding this word transition via xml, so can you please help me,
that how this is possible in VB.Net

--------------------------------------------------------------------------
Post by Danny Mosquito
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
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);
Post by Danny Mosquito
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?
Loading...