Export (0) Print
Expand All

ISpRecoContext::GetAudioOptions (SAPI 5.3)

Speech API 5.3
Microsoft Speech API 5.3

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:
ValueMeaning
SPAO_NONEDo not retain audio for results.
SPAO_RETAIN_AUDIORetain 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

ValueDescription
S_OKFunction completed successfully.
E_POINTEROne 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.


// Declare local identifiers:
HRESULT	                   hr = S_OK;
CComPtr<ISpRecoContext>    cpRecoContext;
WAVEFORMATEX               *pWaveFormatEx;
SPAUDIOOPTIONS             pAudioOptions;
GUID                       guidFormat;

// Check if audio is being retained (default is NO).
hr = cpRecoContext->GetAudioOptions(&pAudioOptions;, NULL, NULL);

if (SUCCEEDED(hr))
{
   // Check what audio format would be retained.
   hr = cpRecoContext->GetAudioOptions(NULL, &guidFormat;, &pWaveFormatEx;);
}

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

// Free the wave format memory.
::CoTaskMemFree(pWaveFormatEx);

// Check if audio is being retained and, if so, what the format is.
hr = cpRecoContext->GetAudioOptions(&pAudioOptions;, &guidFormat;, &pWaveFormatEx;);

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

// Free the wave format memory.
::CoTaskMemFree(pWaveFormatEx);

Development Helpers

Helper Enumerations and FunctionsDescription
SPSTREAMFORMATSAPI supported stream formats
CSpStreamFormatClass for managing SAPI supported stream formats and WAVEFORMATEX structures
Show:
© 2015 Microsoft