Share via


Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

Microsoft Speech Platform

ISpGrammarBuilder::AddWordTransition

ISpGrammarBuilder::AddWordTransition adds a word or a sequence of words to the grammar.

<pre IsFakePre="true" xmlns="http://www.w3.org/1999/xhtml"> <strong>HRESULT AddWordTransition(</strong> <strong> SPSTATEHANDLE</strong> <em>hFromState</em>, <strong> SPSTATEHANDLE</strong> <em>hToState</em>, <strong> LPCWSTR</strong> *<em>psz</em>, <strong> LPCWSTR</strong> *<em>pszSeparators</em>, <strong><a runat="server" href="jj127468(v=msdn.10).md">SPGRAMMARWORDTYPE</a></strong> <em>eWordType</em>, <strong> float</strong> <em>Weight</em>, <strong> const</strong> <strong><a runat="server" href="jj127877(v=msdn.10).md">SPPROPERTYINFO</a></strong> *<em>pPropInfo</em> <strong>);</strong> </pre>

Parameters

  • hFromState
    [in] Handle of the state from which the arc (or sequence of arcs in the case of multiple words) should originate.
  • hToState
    [in] Handle of the state where the arc (or sequence of arcs) should terminate. If NULL, the final arc will be to the (implicit) terminal node of this grammar rule.
  • psz
    [in] Address of a null-terminated string containing the word or words to be added. If psz is NULL, an epsilon arc will be added.
  • pszSeparators
    [in] Address of a null-terminated string containing the transition word separation characters.
    psz points to a single word if pszSeperators is NULL, or else pszSeperators specifies the valid separator characters. This parameter may not contain a forward slash ("/") as that is used for the complex word format.
  • eWordType
    [in] The SPGRAMMARWORDTYPE enumeration that specifies the word type. This supports SPWT_LEXICAL and SPWT_LEXICAL_NO_SPECIAL_CHARS. If neither of these are specified, the method returns E_INVALIDARG.
  • Weight
    [in] Value specifying the arc's relative weight in case there are multiple arcs originating from hFromState.
  • pPropInfo
    [in] The SPPROPERTYINFO structure containing property name and value information that is associated with this arc or sequence of arcs.

Return Values

Value Description
S_OK Function completed successfully.
E_INVALIDARG At least one of psz, pszSeparators, or pPropInfo is invalid or bad; eWordType is a value other than SPWT_LEXICAL; flWeight is less than 0.0; a slash ("/") is used as a separators.
SPERR_WORDFORMAT_ERROR Invalid word format.
E_OUTOFMEMORY Exceeded available memory.
FAILED(hr) Appropriate error message.

Remarks

When specifying a word in Display/Lexical/Pronunciation (DLP) format for the psz parameter, you must separate the word types with forward slashes, and terminate the parameter with a semi-colon (003B). You cannot terminate the parameter with the full-width semi-colon (FF1B), as this will generate an error on compiling the grammar. The following example specifies a display form (in line) and a lexical form (inline) for the word to add, followed by a regular semi-colon:

<pre IsFakePre="true" xmlns="http://www.w3.org/1999/xhtml"> hr = cpRecoGrammar-&gt;AddWordTransition(hsSendMail, hsBeforeDictation, L "/in line/inline/;", L" ", SPWT_LEXICAL, NULL, NULL); </pre>