Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

SpeechRecoContext RetainedAudioFormat Property (SAPI 5.3)

Speech API 5.3
Microsoft Speech API 5.3

Interface: ISpeechRecoContext

RetainedAudioFormat Property


The RetainedAudioFormat property gets and sets the format of audio retained by the recognition context.

By default, the retained audio format will be the same as the input audio format. The input audio format is retrieved by calling Recognizer.GetFormat with SFTInput as the parameter. The audio format may be set, or reset if the format has previously changed, to the same format as the engine uses by passing Nothing in as the parameter.


Syntax

Set: SpeechRecoContext.RetainedAudioFormat = SpAudioFormat
Get: SpAudioFormat = SpeechRecoContext.RetainedAudioFormat

Parts

SpeechRecoContext
The owning object.
SpAudioFormat
Set: An SpAudioFormat object that sets the audio format.
Get: An SpAudioFormat object that returns the audio format.

Remarks

The recognition context's RetainedAudio need not be set to SRAORetainAudio for RetainedAudioFormat to be called successfully. RetainedAudioFormat indicates the format in which the audio would be retained, regardless of whether it is currently retained.

Example

The following Visual Basic form code demonstrates retrieving the audio format of the audio input stream, through the RetainedAudioFormat reference. To run this code, paste it into the Declarations section of a form that contains no controls.


Option Explicit

Private Sub Form_Load()

    Dim AudioFormat As SpAudioFormat
    Dim Recognizer As SpSharedRecognizer
    Dim RecoContext As SpSharedRecoContext

    On Error GoTo EH

    Set Recognizer = New SpSharedRecognizer
    Set RecoContext = Recognizer.CreateRecoContext
    Set AudioFormat = RecoContext.RetainedAudioFormat
    MsgBox AudioFormat.Type, vbInformation
    End

EH:
    If Err.Number Then ShowErrMsg
End Sub

Private Sub ShowErrMsg()

    ' Declare identifiers:
    Dim T As String

    T = "Desc: " & Err.Description & vbNewLine
    T = T & "Err #: " & Err.Number
    MsgBox T, vbExclamation, "Run-Time Error"
    End

End Sub
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.