ISpRecoContext::GetAudioOptions (SAPI 5.4)

Microsoft Speech API 5.4

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
    SPAO_NONE
    SPAO_RETAIN_AUDIO
  • 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
S_OK
E_POINTER
FAILED(hr)

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 Functions
SPSTREAMFORMAT
CSpStreamFormat