ISpRecoContext::GetStatus (Microsoft Speech Platform)

Microsoft Speech Platform SDK 11

Microsoft Speech Platform

ISpRecoContext::GetStatus

ISpRecoContext::GetStatus retrieves current state information associated with a context (e.g., last SR engine requested UI, audio signal status, etc.).

HRESULT GetStatus(
   SPRECOCONTEXTSTATUS   *pStatus
);

Parameters

pStatus
[out] Address of the SPRECOCONTEXTSTATUS structure that receives the context state information.

Return values

Value Description
S_OK Function completed successfully.
E_POINTER pStatus is invalid or bad.
FAILED (hr) Appropriate error message.

Remarks

A graphical application that is interested in SPEI_REQUEST_UI events from the SR engine can call ISpRecoContext::GetStatus, and check the szRequestTypeOfUI field to check the last requested UI-type. After the application has called ISpRecognizer::DisplayUI, the SR engine can clear the szRequestTypeOfUI field.

An application can also periodically query the recognition context status to check the audio signal quality (see also SPINTERFERENCE) and respond appropriately. An application can prompt the user to access the SR engine's microphone training UI to improve the audio signal quality, or prompt the user to modify the audio settings using Speech properties in Control Panel.

Example

The following code snippet illustrates the use of ISpRecoContext::GetStatus for responding to SR engine UI requests.


// Declare local identifiers:
HRESULT                    hr = S_OK;
CComPtr<ISpRecoContext>    cpRecoContext;
CComPtr<ISpRecognizer>     cpRecognizer;
SPRECOCONTEXTSTATUS        contextStatus;
BOOL                       fSupported;
	
// Assume UI request [SPEI_REQUEST_UI] has been received.

// Check what kind of UI the SR Engine wants.
hr = cpRecoContext->GetStatus(&contextStatus;);

if (SUCCEEDED(hr))
{
   // Get a reference to the SR Engine.
   hr = cpRecoContext->GetRecognizer(&cpRecognizer;);
}

if (SUCCEEDED(hr))
{
   // Sanity check that the UI type is supported.
   hr = cpRecognizer->IsUISupported(contextStatus.szRequestTypeOfUI, NULL, NULL, &fSupported;);
}

if (SUCCEEDED(hr))
{
   // Ask the SR engine to display the UI and use the default window title.
   hr = cpRecognizer->IsUISupported(contextStatus.szRequestTypeOfUI, NULL, NULL, &fSupported;);
}

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