ISpRecoContext::Resume

Microsoft Speech SDK

The Microsoft.com Speech website Microsoft Speech SDK SAPI 5.1

ISpRecoContext::Resume

ISpRecoContext::Resume releases the SR engine from the paused state and restarts the recognition process.

HRESULT  Resume (
  DWORD dwReserved
);

Parameters

dwReserved
[in] Reserved, must be zero.

Return values

Value Description
S_OK Function completed successfully.
E_INVALIDARG dwFlags is not set to zero.

Remarks

This method must be called after a call to ISpRecoContext::Pause, a bookmark event occurs that pauses the recognition engine, or an auto-pause rule is recognized (see ISpRecoGrammar::SetRuleState).

The caller must call Resume once for every call that is made to ISpRecoContext::Pause.

Example

The following code snippet illustrates the use of ISpRecoContext::Resume after a call to ISpRecoContext::Pause

    HRESULT hr = S_OK;

    // setup the recognition context
    // ...

    // pause the context so that event notifications are not received
    hr = cpRecoContext->Pause( NULL );
    // Check hr

    // [quickly] perform the processing - see ISpRecoContext::Pause Remarks section
    // ...

    hr = cpRecoContext->Resume( NULL );
    // Check hr

    // applications will start receiving event notifications again

The following code snippet illustrates the use of ISpRecoContext::Resume with an "auto-pause" rule.

    HRESULT hr = S_OK;

    // setup the recognition context and grammar
    // ...

    // activate a top-level rule as an "auto-pause" rule
    hr = cpRecoGrammar->SetRuleState( MY_AUTOPAUSE_RULE, NULL, SPRS_ACTIVE_WITH_AUTO_PAUSE);
    // Check hr

    // get the recognition event for MY_AUTOPAUSE_RULE in a CSpEvent object
    // ...

    // assert that the recognition context paused after the "auto-pause" rule was recognized
    SPDBG_ASSERT(spEvent.IsPaused());

    // deactivate the "auto-pause" rule
    hr = cpRecoGrammar->SetRuleState( MY_AUTOPAUSE_RULE, NULL, SPRS_INACTIVE );
    // Check hr

    // activate the second rule
    hr = cpRecoGrammar->SetRuleState( MY_SECOND_RULE, NULL, SPRS_ACTIVE );
    // Check hr

    // Since the context was paused from the "auto-pause" rule, it must now be reactivated to recognize the second rule
    hr = cpRecoContext->Resume( NULL );
    // Check hr

    // get the second recognition...