Bagikan melalui


Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

RecognitionEventArgs.Result Property

Gets the results of the speech or DTMF recognition operation.

Namespace:  Microsoft.Speech.Recognition
Assembly:  Microsoft.Speech (in Microsoft.Speech.dll)

Syntax

'Declaration
Public ReadOnly Property Result As RecognitionResult
    Get
'Usage
Dim instance As RecognitionEventArgs
Dim value As RecognitionResult

value = instance.Result
public RecognitionResult Result { get; }

Property Value

Type: Microsoft.Speech.Recognition.RecognitionResult
The RecognitionResult that contains the results of the speech or DTMF recognition operation.

Remarks

The RecognitionResult object derives from RecognizedPhrase and contains full information about a phrase returned by a recognition operation. You can obtain a list off all the recognition candidates from the Alternates property.

Examples

The example below shows the use Result to obtain an instance of RecognitionResult, which is then used to display information about the results of a speech recognition operation.

       // Display the semantics, rules, and alternates of the result.
        private void DisplayResult(RecognitionEventArgs eventArgs)
        {

            // Clear results, semantic XML, semantics tree, and alternates.
            _recognitionSmlBrowser.Navigate("about:blank");
            _semanticsTreeView.Nodes.Clear();
            _alternatesListBox.Items.Clear();
            _recognitionInfo.Text = null;
            _recognizedTextDisplay.Text = null;


            //Obtain result from RecognitionEventArg passed in.

            if (eventArgs != null && eventArgs.Result != null)
            {
                RecognitionResult result = eventArgs.Result;
                //Set Text color on the basis of the event type passed in.
                _recognitionInfo.Text = null;
                switch (eventArgs.GetType().ToString())
                {

                    case "Microsoft.Speech.Recognition.SpeechHypothesizedEventArgs":
                       _recognizedTextDisplay.ForeColor = Color.Black;
                        _recognizedTextDisplay.Text = result.Text;
                        _recognitionInfo.Text = null;
                        break;
                    case "Microsoft.Speech.Recognition.SpeechRecognitionRejectedEventArgs":
                        _recognizedTextDisplay.ForeColor = Color.OrangeRed;
                        _recognizedTextDisplay.Text ="Unable to Recognize Input";
                        DisplaySemanticsSML(result);
                        DisplaySemanticsTreeView(result);
                        _recognitionInfo.Text = null;
                        break;
                    case "Microsoft.Speech.Recognition.SpeechRecognizedEventArgs":
                        _recognizedTextDisplay.ForeColor = Color.Green;
                        _recognizedTextDisplay.Text = result.Text;
                        _recognitionInfo.Text =
                            "Confidence Level:    " + result.Confidence + Environment.NewLine
                          + "Recognizing Grammar: " + result.Grammar.Name + Environment.NewLine
                          + ((result.Grammar.RuleName != null) ? ("Recognizing Rule   : " + result.Grammar.RuleName) : "");
                        DisplaySemanticsSML(result);
                        DisplaySemanticsTreeView(result);
                        break;
                    default:
                        _recognizedTextDisplay.ForeColor = Color.Black;
                        break;
                }

                _recognizedTextDisplay.Show();
                _recognitionInfo.Show();

                DisplayAlternates(result);
            }
        }

See Also

Reference

RecognitionEventArgs Class

RecognitionEventArgs Members

Microsoft.Speech.Recognition Namespace

RecognitionEventArgs

RecognitionResult