SpeechRecognitionResult.TextConfidence property

 

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

Syntax

public SpeechRecognitionConfidence TextConfidence { get; }

Property Value

Type: Bing.Speech.SpeechRecognitionConfidence

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

Remarks

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.

private async void SpeakButton_Click(object sender, RoutedEventArgs e)
{
    var result = await SR.RecognizeSpeechToTextAsync();
    ConfidenceText.Text = getConfidence(result.TextConfidence);
    FinalResult.Text = result.Text;
}

private string getConfidence(SpeechRecognitionConfidence confidence)
{
    switch (confidence)
    {
        case SpeechRecognitionConfidence.High:
            return("I am almost sure you said:");
        case SpeechRecognitionConfidence.Medium:
            return("I think you said:");
        case SpeechRecognitionConfidence.Low:
            return("I think you might have said:");
        case SpeechRecognitionConfidence.Rejected:
            return("I'm sorry, I couldn't understand you."
            + " Please click the Cancel button and try again.");
    }
}
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.");
    }
}

Caution

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