SpeechRecognitionResult.TextConfidence property

Bing
 

The TextConfidence property specifies the estimated accuracy of the current SpeechRecognitionResult.

public SpeechRecognitionConfidence TextConfidence { get; }

Type: Bing.Speech.SpeechRecognitionConfidence

An enumeration value that specifies the estimated accuracy of the current SpeechRecognitionResult.

The speech recognizer uses predefined grammars, which represent common linguistic patterns, to interpret likely input from the user. It then rates each possible interpretation by its likelihood of being correct, and uses that value to set the TextConfidence property. For more information, see the SpeechRecognitionConfidence enumeration documentation.

Example

The following example starts speech recognition, and then send an assessment of TextConfidence to a TextBlock before sending the final result text to an adjacent TextBlock.

function speakButton_Click() {
    SR.recognizeSpeechToTextAsync()
        .then(
            function (result) {
                if (typeof (result.text) == "string") {
                    var tc = GetConfidence(result.textConfidence);
                    document.getElementById('ConfidenceText').innerHTML = window.toStaticHTML(tc); 
                    document.getElementById('ResultText').innerHTML = result.text;
                else {
                    // Handle speech that is too quiet or unintelligible.
                    s = "I'm sorry. I couldn't understand you."
                }
            })
}

function GetConfidence(confidence) {
    switch (confidence) {
        case Bing.Speech.SpeechRecognitionConfidence.high:
            return ("I am almost sure you said:");
        case Bing.Speech.SpeechRecognitionConfidence.medium:
            return ("I think you said:");
        case Bing.Speech.SpeechRecognitionConfidence.low:
            return ("I think you might have said:");
        case Bing.Speech.SpeechRecognitionConfidence.rejected:
            return ("I'm sorry, I couldn't understand you."
            + " Please click the Cancel button and try again.");
    }
}
System_CAPS_cautionCaution

When collecting speech results or intermediate results in a JavaScript application, quiet or unclear speech may cause the recognizeSpeechToTextAsync() method to return an error object in place of the result text. To maintain smooth program flow, verify that the result text is a string before attempting to read it. For more information, see How to: Add the Bing Speech Recognition Control to an application with a custom UI.

Requirements

Minimum Supported Client

Windows 8

Required Extensions

Bing.Speech

Namespace

Bing.Speech

Show: