You are reading help file online using chmlib.com
|
Interface: ISpeechRecoContext Events
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.
SpeechRecoContext.FalseRecognition(
StreamNumber As Long,
StreamPosition As Variant,
Result As ISpeechRecoResult
)
There are three possible results from a recognition attempt:
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:
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
You are reading help file online using chmlib.com
|