Interface: ISpeechRecoContext Events
Interference Event
The Interference event occurs when the speech recognition (SR) engine encounters interference in the input audio stream.
Interference may be caused by several factors of which six common ones are listed in the enumeration SpeechInterference. The Interference event indicates that the engine detected a condition which could prevent the optimal recognition process. Interference does not prevent the completion of the recognition. However, applications receiving this event may experience a lower quality recognition (the final text does not accurately reflect the spoken text) as the sound quality prevented a successful recognition.
SpeechRecoContext.Interference(
StreamNumber As Long,
StreamPosition As Variant,
Interference As SpeechInterference
)
Parameters
- StreamNumber
- Specifies the stream number.
- StreamPosition
- Specifies the position within the stream.
- Interference
- A SpeechInterference constant that specifies the type of interference.
Example
The following Visual Basic form code demonstrates the use of the Interference event. The application displays the text of a successful recognition and also one of two common interferences results.
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 and activates a dictation grammar. The interference may be intentional caused by either making a sudden loud noise (such as a sharp increase of your voice or by clapping your hands near the microphone) or talking very quickly.
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_Interference(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal Interference As SpeechLib.SpeechInterference)
Select Case Interference
Case SITooFast
RC.Voice.Speak "Too fast. Speak more slowly."
Case SITooLoud
RC.Voice.Speak "Too loud. Speak softly."
Label2.Caption = "SITooLoud detected at stream position: " & StreamPosition
End Select
End Sub
Private Sub RC_Recognition(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal RecognitionType As SpeechLib.SpeechRecognitionType, ByVal Result As SpeechLib.ISpeechRecoResult)
Label1.Caption = Result.PhraseInfo.GetText
End Sub