Note

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

Microsoft Speech Platform

ISpGrammarBuilder::CreateNewState

ISpGrammarBuilder::CreateNewState creates a new state in the same grammar rule as hState.

<pre IsFakePre="true" xmlns="http://www.w3.org/1999/xhtml"> <strong>HRESULT CreateNewState(</strong> <strong> SPSTATEHANDLE</strong> <em>hState</em>, <strong> SPSTATEHANDLE</strong> *<em>phState</em> <strong>);</strong> </pre>

Parameters

  • hState
    [in] Handle to any existing state in the grammar rule.
  • phState
    [out] Address of the state handle for a new state in the same grammar rule.

Return Values

Value Description
S_OK Function completed successfully.
E_INVALIDARG The hState is not a valid state handle.
E_POINTER The phState pointer is invalid.
E_OUTOFMEMORY Exceeded available memory.

Example

The following code snippet illustrates the use of CreateNewState.

`

// Declare local identifiers:
HRESULT                       hr = S_OK;
CComPtr<ISpGrammarBuilder>    cpGrammarBuilder;
SPSTATEHANDLE                 hInit;
SPSTATEHANDLE                 hState;
SPSTATEHANDLE                 hState2;

hr = cpGrammarBuilder->GetRule(L"rule1", 1, 0, TRUE, &hInit;);

if (SUCCEEDED (hr)) { // Call CreateNewState using the initial state. hr = cpGrammarBuilder->CreateNewState(hInit, &hState;); }

if (SUCCEEDED (hr)) { // Call CreateNewState using hState != hInit. hr = cpGrammarBuilder->CreateNewState(hState, &hState2;); }

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

`