ISpeechRecoResult::AudioFormat Property

Microsoft Speech SDK

Intelligent Interface Technologies Home Page Microsoft Speech SDK

Speech Automation 5.1

Object: ISpeechRecoResult

AudioFormat Property

The AudioFormat property gets or sets the audio stream format.

The controlling recognition context must retain the audio portion of the recognition. By default, a recognition context does not retain audio; that is, RecoContext.RetainedAudio is set to SRAONone. Attempts to access this retained audio stream, including references to AudioFormat, cause an SPERR_NO_AUDIO_DATA error. To retain the audio, use ISpeechRecoContext.RetainedAudio passing SRAORetainAudio as the parameter.


Syntax

Get: SpAudioFormat = ISpeechRecoResult.AudioFormat
Set: ISpeechRecoResult.AudioFormat = SpAudioFormat

Parts

ISpeechRecoResult
The owning object.
SpAudioFormat
An object variable representing an audio output device.
Get: The token represents the current audio output device of the voice.
Set: The token represents the audio output device assigned to the voice.
In either case, the format for SpAudioFormat.Type is of type SpeechAudioFormatType.

Example

The following code snippet demonstrates retrieving and setting the audio format.

The following code snippets assume a valid RecoResult. The following code demonstrates setting the recognition context.

Set RC = New SpSharedRecoContext
RC.RetainedAudio = SRAORetainAudio

'Get audio format
Dim GetFormat as SpAudioFormat
Set Format = RecoResult.AudioFormat

'Set audio format
Dim SetFormat as SpAudioFormat
Set SetFormat = CreateObject("SAPI.SpAudioFormat")
    
SetFormat.Type = SAFT11kHz16BitMono
Set RecoResult.AudioFormat = SetFormat