Share via


Note

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

Microsoft Speech Platform

ISpRecoGrammar::GetGrammarState

ISpRecoGrammar::GetGrammarState retrieves the current state of the recognition grammar.

<pre IsFakePre="true" xmlns="http://www.w3.org/1999/xhtml"> <strong>HRESULT GetGrammarState(</strong><a runat="server" href="jj127467(v=msdn.10).md"><strong>SPGRAMMARSTATE</strong></a> *<em>peGrammarState</em> <strong>);</strong> </pre>

Parameters

  • peGrammarState
    [out] Address of the SPGRAMMARSTATE enumeration that receives the grammar state information.

Return Values

Value Description
S_OK Function completed successfully.
E_POINTER One of the pointers is invalid or bad.
FAILED(hr) Appropriate error message.

Example

The following code snippet illustrates the use of ISpRecoGrammar::GetGrammarState to query the default state of an SpRecoGrammar object.

`

// Declare local identifiers:
HRESULT                      hr = S_OK;
CComPtr<ISpRecoGrammar>      cpRecoGrammar;
CComPtr<ISpRecoContext>      cpRecoContext;
ULONGLONG                    ullGrammarId = 0;
SPGRAMMARSTATE               grammarState;

// Create a new grammar object. hr = cpRecoContext->CreateGrammar(ullGrammarId, &cpRecoGrammar;);

if (SUCCEEDED(hr)) { // Query the default grammar state. hr = cpRecoGrammar->GetGrammarState(&grammarState;); }

if (SUCCEEDED(hr)) { // ASSERT that grammarState = SPGS_ENABLED. }

`

Remarks

The default grammar state is SPGS_ENABLED. See also ISpRecoGrammar::SetGrammarState.