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.
HRESULT ResetGrammar(
LANGID NewLanguage
);
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.
}