Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Microsoft Speech API 5.3
Interface: ISpeechRecoContext Events
SoundEnd Event
The SoundEnd event occurs when the speech recognition (SR) engine encounters an end of sound in the audio input stream.
SoundStart indicates a sound level significant enough to be a voice. When that sound stops, a SoundEnd event is generated. A recognition attempt occurs only after a SoundEnd event; hence, long continuous speaking periods may take an equally long time to process.
Light background noise will not register as an input sound. Likewise a loud noise will be considered the start of an input sound. If the sound is constant, a time-out occurs sending a SoundEnd event.
SpeechRecoContext.SoundEnd(
StreamNumber As Long,
StreamPosition As Variant
)
Parameters
- StreamNumber
Specifies the StreamNumber. - StreamPosition
Specifies the StreamPosition.
Example
The following Visual Basic form code demonstrates the use of the SoundStart and SoundEnd events. The application displays a stream number and notifications that a sound has begun or ended. It also displays a successful recognition result.
To run this code, create a form with the following controls:
- Two labels called Label1 and Label2
Paste this code into the Declarations section of the form.
The Form_Load procedure creates and activates a dictation grammar.
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)
Label1.Caption = Result.PhraseInfo.GetText
End Sub
Private Sub RC_SoundEnd(ByVal StreamNumber As Long, ByVal StreamPosition As Variant)
Label2.Caption = "Sound end at position: " & StreamPosition
End Sub
Private Sub RC_SoundStart(ByVal StreamNumber As Long, ByVal StreamPosition As Variant)
Label2.Caption = "Sound start"
End Sub