RecognizedPhrase.Confidence Property
Returns the measure of certainty for a RecognizedPhrase returned by a recognition engine.
Namespace: Microsoft.Speech.Recognition
Assembly: Microsoft.Speech (in microsoft.speech.dll)
Syntax
'Declaration
Property Value
Returns a float a relative measure of the certainty of correct recognition for the phrase information returned in the current RecognizedPhrase instance.
Remarks
The values returned by Confidence are purely relative and unique to each recognition engine.
There is no definition how confidence values between two different recognition engines compare.
The values are used to rank alternative candidate phrases returned by the Alternates property on RecognitionResult objects.
Example
The example below show a display function which provides information about a recognized phrase from an instance of RecognizedPhrase to a user interface.
The use of Confidence in the code below is highlighted.
internal static void DisplayBasicPhraseInfo(Label label, RecognizedPhrase result, SpeechRecognizer recognizer) {
if (result != null && label != null) {// Blank
if (recognizer != null) { //Clear
label.Text += String.Format(
" Recognizer currently at: {0} mSec\n" +
" Audio Device currently at: {1} mSec\n",
recognizer.RecognizerAudioPosition.TotalMilliseconds,
recognizer.AudioPosition.TotalMilliseconds);
}
if (result != null) { //Clear
RecognitionResult recResult = result as RecognitionResult;
if (recResult != null) {
RecognizedAudio resultRecognizedAudio = recResult.Audio;
if (resultRecognizedAudio == null) {
label.Text += String.Format(
" Emulated input\n");
} else {
label.Text += String.Format(
" Candidate Phrase at: {0} mSec\n" +
" Phrase Length: {1} mSec\n" +
" Input State Time: {2}\n" +
" Input Format: {3}\n",
resultRecognizedAudio.AudioPosition.TotalMilliseconds,
resultRecognizedAudio.Duration.TotalMilliseconds,
resultRecognizedAudio.StartTime.ToShortTimeString(),
resultRecognizedAudio.Format.EncodingFormat.ToString());
}
}
label.Text += String.Format(" Confidence Level: {0}\n", result.Confidence);
if (result.Grammar != null) {
label.Text += String.Format(
" Recognizing Grammar: {0}\n" +
" Recognizing Rule: {1}\n",
((result.Grammar.Name != null) ? (result.Grammar.Name) : "None"),
((result.Grammar.RuleName != null) ? (result.Grammar.RuleName) : "None"));
}
if (result.ReplacementWordUnits.Count != 0) {
label.Text += String.Format(" Replacement text:\n");
foreach (ReplacementText rep in result.ReplacementWordUnits) {
label.Text += String.Format(" At index {0} for {1} words. Text: {2}\n",
rep.FirstWordIndex, rep.CountOfWords, rep.Text);
}
label.Text+=String.Format("\n\n");
}
}
}
}
Thread Safety
All public static (Shared in Visual Basic) members of this type are thread-safe. Instance members are not guaranteed to be thread-safe.
Platforms
Development Platforms
Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Vista Ultimate Edition, Windows Vista Business Edition, Windows Vista Enterprise Edition
Target Platforms
See Also
Reference
RecognizedPhrase Class
RecognizedPhrase Members
Microsoft.Speech.Recognition Namespace