Note

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

Microsoft Speech Platform

ISpGrammarBuilder::Commit

ISpGrammarBuilder::Commit performs consistency checks of the grammar structure, creates the serialized format, saves the grammar structure, or reloads the grammar structure.

The grammar structure may be saved to the stream provided by SetSaveObjects, or reloaded into the SR engine. Commit must be called before any changes to the grammar can take effect.

Commit can be used to optimize the grammar structure. Typically the grammar optimization is done in the final Commit() call. The span of the semantic properties may be incorrect after grammar optimization.

<pre IsFakePre="true" xmlns="http://www.w3.org/1999/xhtml"> <strong>HRESULT Commit(</strong> <strong>DWORD</strong> <em>dwFlags</em> <strong>);</strong> </pre>

Parameters

  • dwFlags
    [in] Bitwise flags of type SPGRAMBUILDCOMMITFLAGS. If SPGBCF_NONE, then the grammar structure is NOT optimized. If SPGBCF_OPTIMIZE, then the grammar structure is optimized.

Return Values

Value Description
S_OK Function completed successfully.
E_INVALIDARG dwFlags is not SPGBCF_NONE and not SPGBCF_OPTIMIZE.
SPERR_UNINITIALIZED Stream not initialized.  Call SetSaveObjects before Commit.
SPERR_NO_RULES A grammar must have at least one rule and one word.
SPERR_NO_TERMINATING_RULE_PATH At least one rule is not empty but has no terminating path (path of transitions from the initial state to a NULL state).
SPERR_CIRCULAR_RULE_REF At least one rule has left recursion (a direct or indirect rule reference to itself originated from the initial state).
SPERR_STATE_WITH_NO_ARCS At least one rule has a node with no outgoing transitions.
SPERR_EXPORT_DYNAMIC_RULE Dynamic rules or rules referencing dynamic rules (directly or indirectly) cannot be exported.