ISpRecognizer::DisplayUI

Microsoft Speech SDK

The Microsoft.com Speech website Microsoft Speech SDK SAPI 5.1

ISpRecognizer::DisplayUI

ISpRecognizer::DisplayUI displays the requested UI component from the underlying SR engine.

[local] HRESULT DisplayUI(
   HWND           hwndParent,
   const WCHAR   *pszTitle,
   const WCHAR   *pszTypeOfUI,
   void          *pvExtraData,
   ULONG          cbExtraData
);

Parameters

hwndParent
[in] Specifies the handle of the parent window.
pszTitle
[in] Address of a null-terminated string containing the window title. Set this value to NULL to indicate that the SR engine should use its default window title for this UI type. 
pszTypeOfUI
[in] Address of a null-terminated string containing the UI type information.
pvExtraData
[in] Additional information for the call. The SR engine implementer dictates the format and use of the data provided.
cbExtraData
[in] Size, in bytes, of the contents of pvExtraData. The SR engine implementer dictates the format and usage of the data provided.

Return values

Value Description
S_OK Function completed successfully.
S_FALSE The UI is supported but not with the current run-time environment or parameters.
FAILED(hr) Appropriate error message.

Remarks

SAPI 5 speech recognition engines are capable of sending UI requests back to the application using SPEI_REQUEST_UI. For example, if the SR engine is receiving a poor audio input signal, it may request the user to perform Microphone Training (see SPDUI_MicTraining). The application can receive these requests by calling ISpRecognizer::SetInterest with SPEI_REQUEST_UI. When the UI request is received, it can call ISpRecognizer::DisplayUI at an appropriate point. The typical SR engine UI requests could be User Training (see SPDUI_UserTraining), Microphone Training (see SPDUI_MicTraining), and Lexicon Updates (see SPDUI_AddRemoveWord). An application can call DisplayUI at any time, and does not necessarily have to wait for a UI request from the SR engine.

To best apply ISpRecognizer::DisplayUI, call ISpRecognizer::IsUISupported with a specific UI type before calling DisplayUI. (see the SR Engine Guide for further information on how an SR engine should implement UI.

The call to DisplayUI is synchronous, so the call will not return until the UI has been closed.

Example

The following code snippet illustrates the use of ISpRecognizer::DisplayUI using SPDUI_UserTraining.

    HRESULT hr = S_OK;

    // display user training UI for the current recognizer
    hr = cpRecognizer->DisplayUI(MY_HWND, MY_APP_USER_TRAINING, SPDUI_UserTraining, NULL, NULL);
    // Check hr