Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
FalseRecognition Event

SpeechRecoContext FalseRecognition Event (SAPI 5.3)

Speech API 5.3
Microsoft Speech API 5.3

Interface: ISpeechRecoContext Events

FalseRecognition Event

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

A false recognition is the result of a recognition attempt in which either the word or phrase does not exist in the grammar, or that the speech does not adequately meet the confidence score for the application. Although applicable to dictation grammars, it is more common with command and control instances, because the available words are significantly restricted.

The recognition result returned with a FalseRecognition is still valid and contains all the information a Recognition event does, including the text. Although the text is not necessarily representative of the intended speech, it represents the best estimate of that speech. If using alternates (automatically chosen alternate phrase selections for a recognition), the first alternate returned will likely be the same as the FalseRecognition result.

     StreamNumber As Long,
     StreamPosition As Variant,
     Result As ISpeechRecoResult


Specifies the StreamNumber.
Specifies the StreamPosition.
An ISpeechRecoResult object containing the recognition results.


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.


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

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. The grammar file sol.xml also needs to be created and use the XML code from the RecoCC sample application.

The sol.xml file has only one phrase that can be recognized. To use this application speak the phrase "new game" and it should be successfully recognized and displayed in Labell. Any other word or phrase should not be recognized and will display in Label2.

Public WithEvents RC As SpSharedRecoContext
Public myGrammar As ISpeechRecoGrammar

Private Sub Form_Load()
    Set RC = New SpSharedRecoContext

    Set myGrammar = RC.CreateGrammar
    myGrammar.CmdLoadFromFile "sol.xml", SLODynamic
    myGrammar.CmdSetRuleIdState 0, 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
    Label2.Caption = ""
End Sub

Private Sub RC_FalseRecognition(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal Result As SpeechLib.ISpeechRecoResult)
    Label2.Caption = Result.PhraseInfo.GetText
    Label1.Caption = ""
End Sub
© 2015 Microsoft