Interface: ISpeechPhraseProperty
EngineConfidence Property
The EngineConfidence property returns the confidence value for this semantic property computed by the speech recognition (SR) engine.
The value range is specific to each SR engine and not standard across multiple SR engines.
Syntax
Set: | (This property is read-only) |
Get: | Single = ISpeechPhraseProperty.EngineConfidence |
Parts
- ISpeechPhraseProperty
- The owning object.
- Single
-
Set: (This property is read-only)
Get: A Single variable that gets the property.
Example
The following code demonstrates retrieving the Engine Confidence property from a command and control recognition. One label displays the recognized text and the other label displays the rule name activated along with the engine confidence associated with that 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 command and control grammar. The grammar file sol.xml is the solitaire grammar provided with the SDK. The path listed is for a standard SDK install and may be changed as needed.
If "play the red five" has been recognized, the application displays the recognized text in Label1. Label2 displays the rule name and the confidence for that recognition. In this case, the rules would be "color" and "rank" along with their Engine confidence values.
Option Explicit
Public WithEvents RC As SpSharedRecoContext
Public myGrammar As ISpeechRecoGrammar
Private Sub Form_Load()
On Error GoTo EH
Set RC = New SpSharedRecoContext
Set myGrammar = RC.CreateGrammar
myGrammar.CmdLoadFromFile "C:\Program Files\Microsoft Speech SDK 5.4\Samples\Common\sol.xml", SLODynamic
myGrammar.CmdSetRuleIdState 0, SGDSActive
EH:
If Err.Number Then ShowErrMsg
End Sub
Private Sub RC_FalseRecognition _
(ByVal StreamNumber As Long, _
ByVal StreamPosition As Variant, _
ByVal Result As SpeechLib.ISpeechRecoResult)
Beep
Label1.Caption = "(no recognition)"
Label2.Caption = ""
End Sub
Private Sub RC_Recognition _
(ByVal StreamNumber As Long, _
ByVal StreamPosition As Variant, _
ByVal RecognitionType As SpeechLib.SpeechRecognitionType, _
ByVal Result As SpeechLib.ISpeechRecoResult)
Dim i As Long
On Error GoTo EH
Label1.Caption = Result.PhraseInfo.GetText & vbCrLf
Label2.Caption = "Rule Properties Found : " & Result.PhraseInfo.Properties.Count & vbCrLf
For i = 0 To Result.PhraseInfo.Properties.Count - 1
Label2.Caption = Label2.Caption & Result.PhraseInfo.Properties.Item(i).Name
Label2.Caption = Label2.Caption & " Engine Confidence : " & Result.PhraseInfo.Properties.Item(i).EngineConfidence & vbCrLf
Next
EH:
If Err.Number Then ShowErrMsg
End Sub
Private Sub ShowErrMsg()
' Declare identifiers:
Const NL = vbNewLine
Dim T As String
T = "Desc: " & Err.Description & NL
T = T & "Err #: " & Err.Number
MsgBox T, vbExclamation, "Run-Time Error"
End
End Sub