Share via


Note

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

Microsoft Speech Platform

ISpGrammarBuilder::ResetGrammar

ISpGrammarBuilder::ResetGrammar clears all grammar rules (un-defines them) and resets the grammar's language to NewLanguage. The state handles for this grammar are no longer valid after this point.

<pre IsFakePre="true" xmlns="http://www.w3.org/1999/xhtml"> <strong>HRESULT ResetGrammar(</strong> <strong> LANGID</strong> <em>NewLanguage</em> <strong>);</strong> </pre>

Parameters

  • NewLanguage
    [in] Language identifier associated with the grammar rule.

Return Values

Value Description
S_OK Function completed successfully.
FAILED(hr) Appropriate error message.

Example

The following code snippet illustrates the use of ResetGrammar.

`

// Declare local identifiers:
HRESULT                       hr = S_OK;
CComPtr<ISpGrammarBuilder>    cpGrammarBuilder;

// ResetGrammar when no rules. hr = cpGrammarBuilder->ResetGrammar(409);

if (SUCCEEDED (hr)) { // Set language to default user language. hr = cpGrammarBuilder->ResetGrammar(SpGetUserDefaultUILanguage()); }

if (SUCCEEDED (hr)) { // Set language to non-english. hr = cpGrammarBuilder->ResetGrammar(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED)); }

if (SUCCEEDED (hr)) { hr = cpGrammarBuilder->ResetGrammar(MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT)); }

if (SUCCEEDED(hr)) { // Do stuff here. }

`