Microsoft Speech SDK
SAPI 5.1
ISpRecoContext::GetAudioOptions
ISpRecoContext::GetAudioOptions retrieves the audio options for the context.
HRESULT GetAudioOptions(
SPAUDIOOPTIONS *Options,
GUID *pAudioFormatId,
WAVEFORMATEX **ppCoMemWFE
);
Parameters
- Options
- [out] Address that will receive pointer to SPAUDIOOPTIONS flag, indicating the options set for this context. If this value is not to be retrieved, specify NULL. The flag can be one of the following values:
-
Value Meaning SPAO_NONE Do not retain audio for results. SPAO_RETAIN_AUDIO Retain audio for all future results. - pAudioFormatId
- [in] Address that will receive the audio stream format type (i.e., GUID). If the application is not interested in the retained audio format, NULL is specified (i.e., ignore both pAudioFormatId and pWaveFormatEx parameters).
- ppCoMemWFE
- [in] Address that will receive a pointer to the audio stream wave format structure (i.e., WAVEFORMATEX). This can be NULL if the application is not interested in the retained audio format. If WAVEFORMATEX data is retrieved, it must be freed using ::CoTaskMemFree().
Return values
Value | Description |
---|---|
S_OK | Function completed successfully. |
E_POINTER | One of the pointers is invalid or bad. |
FAILED(hr) | Appropriate error message. |
Remarks
The default audio options are none (i.e., SPAO_NONE). The default retained audio format is the speech recognition engine's recognition format (see ISpRecognizer::GetFormat with SPWF_SRENGINE).
See also ISpRecoContext::SetAudioOptions.
Example
The following code snippet illustrates the use of ISpRecoContext::GetAudioOptions and querying the different retained audio settings.
HRESULT hr = S_OK;
// check if audio is being retained (default is NO)
hr = cpRecoContext->GetAudioOptions(&pAudioOptions, NULL, NULL);
// Check hr
// check what audio format would be retained
hr = cpRecoContext->GetAudioOptions(NULL, &guidFormat, &pWaveFormatEx);
// Check hr
// ... do stuff
// free the wave format memory
::CoTaskMemFree(pWaveFormatEx);
// check if audio is being retained, and if so what the format is
hr = cpRecoContext->GetAudioOptions(&guid, &guidFormat, &pWaveFormatEx);
// Check hr
// ... do stuff
// free the wave format memory
::CoTaskMemFree(pWaveFormatEx);
Development Helpers
Helper Enumerations and Functions | Description |
---|---|
SPSTREAMFORMAT | SAPI supported stream formats |
CSpStreamFormat | Class for managing SAPI supported stream formats and WAVEFORMATEX structures |