Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

Microsoft Speech Platform

ISpRecoContext::GetAudioOptions

ISpRecoContext::GetAudioOptions retrieves the audio options for the context.

<pre IsFakePre="true" xmlns="http://www.w3.org/1999/xhtml"> <strong>HRESULT GetAudioOptions(</strong> <strong><a runat="server" href="jj127453(v=msdn.10).md">SPAUDIOOPTIONS</a></strong> *<em>Options</em>, <strong>GUID</strong> *<em>pAudioFormatId</em>, <strong>WAVEFORMATEX</strong> **<em>ppCoMemWFE</em> <strong>);</strong> </pre>

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 (that is, a GUID). The application can specify NULL if it is not interested in the retained audio format. This will ignore both the pAudioFormatId and pWaveFormatEx parameters.

  • ppCoMemWFE
    [in] Address that will receive a pointer to the audio stream WAV format structure (that is, 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 not valid or bad.
FAILED(hr) Appropriate error message.

Remarks

The default audio options are none (that is, 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 Description
SPSTREAMFORMAT The stream formats supported by the Speech Platform.
CSpStreamFormat Class for managing the stream formats and WAVEFORMATEX structures supported by the Speech Platform.