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

SpeechRecognizer AudioInput Property (SAPI 5.3)

Speech API 5.3
Microsoft Speech API 5.3

Interface: ISpeechRecognizer

AudioInput Property

The AudioInput property gets and sets the recognizer's audio input device.


Set: SpeechRecognizer.AudioInput = SpObjectToken
Get: SpObjectToken = SpeechRecognizer.AudioInput


The owning object.
Set: An SpObjectToken object that sets the property. If this parameter is Nothing, the default audio input device will be used.
Get: An SpObjectToken object that sets the property.


The following Visual Basic form code demonstrates the use of the AudioInput property. The code displays the default audio input device. It then sets the recognizer's AudioInput property to Nothing and shows the results. Finally, the procedure lists the names of all available audio input devices.

To run this code, paste it into the Declarations section of a form that contains no controls.

Option Explicit

Dim R As SpeechLib.SpSharedRecognizer
Dim T As SpeechLib.SpObjectToken

Private Sub Form_Load()
    On Error GoTo EH

    Set R = New SpSharedRecognizer

    Debug.Print "New SpSharedRecognizer"
    Debug.Print "   AudioInput: " & R.AudioInput.GetDescription

    Set R.AudioInput = Nothing

    Debug.Print "Set to Nothing"
    Debug.Print "   AudioInput: " & R.AudioInput.GetDescription

    Debug.Print "Show all available inputs"
    For Each T In R.GetAudioInputs
        Debug.Print "   AudioInput: " & T.GetDescription


    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 Sub
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.