Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Microsoft Speech API 5.3
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 |
S_OK |
E_INVALIDARG |
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
// Declare local identifiers:
HRESULT hr = S_OK;
CComPtr<ISpRecoContext> cpRecoContext;
// Set up the recognition context.
// ...
// Pause the context so that event notifications are not received.
hr = cpRecoContext->Pause(NULL);
if (SUCCEEDED(hr))
{
// Quickly perform the processing - see the
// Remarks section in ISpRecoContext::Pause.
// ...
hr = cpRecoContext->Resume(NULL);
}
// Applications will start receiving event notifications again.
if (SUCCEEDED(hr))
{
// Do stuff here.
}
The following code snippet illustrates the use of ISpRecoContext::Resume with an "auto-pause" rule.
// Declare local identifiers:
HRESULT hr = S_OK;
CComPtr<ISpRecoContext> cpRecoContext;
CComPtr<ISpRecoGrammar> cpRecoGrammar;
const WCHAR *MY_AUTOPAUSE_RULE = L"Rule1";
const WCHAR *MY_SECOND_RULE = L"Rule2";
// Set up 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);
if (SUCCEEDED(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.
_ASSERT(spEvent.IsPaused());
// Deactivate the "auto-pause" rule.
hr = cpRecoGrammar->SetRuleState(MY_AUTOPAUSE_RULE, NULL, SPRS_INACTIVE);
if (SUCCEEDED(hr))
{
// Activate the second rule.
hr = cpRecoGrammar->SetRuleState(MY_SECOND_RULE, NULL, SPRS_ACTIVE);
}
if (SUCCEEDED(hr))
{
// Because the context was paused from the "auto-pause" rule,
// it must now be reactivated to recognize the second rule.
hr = cpRecoContext->Resume(NULL);
}
if (SUCCEEDED(hr))
{
// Get the second recognition...
}