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

SpeechRecoContext Recognition Event (SAPI 5.3)

Speech API 5.3
Microsoft Speech API 5.3

Interface: ISpeechRecoContext Events

Recognition Event


The Recognition event occurs when the speech recognition (SR) engine produces a recognition.

This could be considered the most important event for speech recognition because it returns the result of a successful recognition. A successful recognition is recognized a word or phrase that is matched in an open grammar for that recognition context and whose quality of speech meets a minimum confidence score. If neither criteria is met, the engine returns a FalseRecognition event. Spoken content may not meet the confidence score for several reasons including background interference, inarticulate speech or an uncommon word or phrase.

The member Result contains the recognition result object and from that may derive much of the information about the speech.


SpeechRecoContext.Recognition(
     StreamNumber As Long,
     StreamPosition As Variant,
     RecognitionType As SpeechRecognitionType,
     Result As ISpeechRecoResult
)

Parameters

StreamNumber
Specifies the stream number owning the recognition.
StreamPosition
Specifies the position within the stream.
RecognitionType
A SpeechRecognitionType constant that specifies the RecognitionType or the recognition state of the engine.
Result
An ISpeechRecoResult object containing the recognition results.

Remarks

There are three possible results from a recognition attempt:

  1. The first, a Recognition event is the result of a successful recognition. This event indicates that the word or phrase was matched to elements in an open grammar, and that the match had a sufficiently high confidence rating.
  2. The second possible result is a FalseRecognition event. This event indicates that speech was detected but it either did not match words in an open grammar, or the match did not merit a high enough confidence rating. The recognition result returned with a FalseRecognition is still valid and contains all the information of a Recognition event, including the text.
  3. The third possible result is RecognitionForOtherContext event. This event indicates a successful recognition result, but a different recognition context was used to match words. SAPI attempts to match the word or phrase in the current recognition context. However, if no match is possible (perhaps the recognition context is currently inactive, the rule is inactive, or the word or phrase is simply not included in the grammar), SAPI then attempts to find a match in other recognition contexts. If a match is found in another application whose grammar is available, the Recognition event is sent to that application instead and the current application receives a RecognitionForOtherContext event.

Example

The following Visual Basic form code demonstrates the use of the Recognition event. The application displays the text of a successful recognition.

To run this code, create a form with the following control:

  • A label called Label1

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