You are reading help file online using chmlib.com
|
Interface: ISpeechRecognizer
The GetFormat method returns the current input audio format.
The sound format may be different at different times or at different points during processing. For example, the audio format at the time the input reaches the sound device (the audio card for instance) may differ from the audio format by the time it reaches the speech recognition (SR) engine. GetFormat specifies which location should be polled and returns the audio format for that location.
SpeechRecognizer.GetFormat(
Type As SpeechFormatType
) As SpAudioFormat
The GetFormat method returns an SpAudioFormat variable.
This code sample demonstrates the GetFormat method. After a successful recognition, two GetFormat calls poll SAPI for the audio formats of the sound device and the SR engine and display results in a label.
To run this code, create a form with the following controls:
Paste this code into the Declarations section of the form.
The Form_Load procedure creates the recognizer.
Public WithEvents RC As SpSharedRecoContext
Public myGrammar As ISpeechRecoGrammar
Private Sub Form_Load()
Set RC = New SpSharedRecoContext
Set myGrammar = RC.CreateGrammar
myGrammar.DictationSetState SGDSActive
End Sub
Private Sub RC_Recognition(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal RecognitionType As SpeechLib.SpeechRecognitionType, ByVal Result As SpeechLib.ISpeechRecoResult)
Dim audioFormat As SpAudioFormat
Label1.Caption = Result.PhraseInfo.GetText
Set audioFormat = RC.Recognizer.GetFormat(SFTInput)
audioFormatType = audioFormat.Type
Label2.Caption = "Audio input type: " & audioFormat.Type & vbCrLf
Set audioFormat = RC.Recognizer.GetFormat(SFTSREngine)
audioFormatType = audioFormat.Type
Label2.Caption = Label2.Caption & "SR engine input type: " & audioFormat.Type
End Sub
You are reading help file online using chmlib.com
|