Partager via


ISpRecoContext::GetAudioOptions

This method gets audio options for a given stream. The default audio options are none (such as SPAO_NONE). The default retained audio format is the recognition format of the speech recognition (SR) engine. see ISpRecognizer::GetFormat with SPWF_SRENGINE. See also ISpRecoContext::SetAudioOptions.

HRESULT GetAudioOptions(
  SPAUDIOOPTIONS* Options,
  GUID* pAudioFormatId,
  WAVEFORMATEX** ppCoMemWFE
);

Parameters

  • Options
    [out] Pointer to a value indicating the audio option set for the provided format identifier, or NULL if a value is not retrieved. Possible values are defined for SPAUDIOOPTIONS enumeration.
  • pAudioFormatId
    [in] Pointer to an audio stream format identifier (such as a GUID), or to NULL if the application is not interested in the retained audio format. If the application is not interested in the format, it ignores both pAudioFormatId and pWaveFormatEx parameters when calling ISpRecoContext::SetAudioOptions.
  • ppCoMemWFE
    [in] Address of a pointer to a WAVEFORMATEX containing the retained audio format, or to NULL if the application is not interested in the retained audio format. If WAVEFORMATEX data is retrieved, then the application must free it using CoTaskMemFree.

Return Values

The following table shows the possible 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

A related enumeration is SPSTREAMFORMAT, which defines SAPI-supported stream formats. A related class is CspStreamFormat, which manages SAPI-supported stream formats and WAVEFORMATEX structures.

Example

The following code snippet illustrates the use of this method 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 other operations
// 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 other operations
// free the wave format memory
::CoTaskMemFree(pWaveFormatEx);

Requirements

OS Versions: Windows CE .NET 4.1 and later.
Header: Sapi.h, Sapi.idl.
Link Library: Sapilib.lib.

See Also

ISpRecoContext | SAPI Interfaces

 Last updated on Saturday, April 10, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.