Exporter (0) Imprimer
Développer tout

RecognitionResult, classe

Mise à jour : novembre 2007

Represents the result of recognition engine on audio input as detailed information about the best candidate phrases matching phrase, and a list of all candidate matching phrases.

Espace de noms :  System.Speech.Recognition
Assembly :  System.Speech (dans System.Speech.dll)

[SerializableAttribute]
public sealed class RecognitionResult : RecognizedPhrase, 
	ISerializable
/** @attribute SerializableAttribute */ 
public final class RecognitionResult extends RecognizedPhrase implements ISerializable
public final class RecognitionResult extends RecognizedPhrase implements ISerializable

An instance of RecognitionResult returned by a speech recognition operation provides both:

  • Detailed information about the phrase determined by to be the best candidate for matching audio input.

  • A list of all candidate phrases, as RecognizedPhrase objects, ordered by confidence level, and obtained by the Alternates member of [T:System.Speech.Recognition.RecognitionResult.]

RecognitionResult inherits from RecognizedPhrase and is serializable and

An application typically obtains an instance of RecognitionResult from the Result member of the instance of a class derived from RecognitionEventArgs and passed by a speech recognition engine to handlers of SpeechHypothesized, SpeechRecognized or SpeechRecognitionRejected events generated by SpeechRecognizer and SpeechRecognitionEngine, as well as SpeechRecognized events generated byGrammar.

The example below use an instance of RecognitionResult to display information about the results of a speech recognition operation.


       // Displays 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 "System.Speech.Recognition.SpeechHypothesizedEventArgs":
                       _recognizedTextDisplay.ForeColor = Color.Black;
                        _recognizedTextDisplay.Text = result.Text;
                        _recognitionInfo.Text = null;
                        break;
                    case "System.Speech.Recognition.SpeechRecognitionRejectedEventArgs":
                        _recognizedTextDisplay.ForeColor = Color.OrangeRed;
                        _recognizedTextDisplay.Text ="Unable to Recognize Input";
                        DisplaySemanticsSML(result);
                        DisplaySemanticsTreeView(result);
                        _recognitionInfo.Text = null;
                        break;
                    case "System.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);

            }
        }

System.Object
  System.Speech.Recognition.RecognizedPhrase
    System.Speech.Recognition.RecognitionResult

Tous les membres static (Shared en Visual Basic) publics de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.

Windows Vista, Windows XP SP2, Windows Server 2003

Le .NET Framework et le .NET Compact Framework ne prennent pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.

.NET Framework

Pris en charge dans : 3.5, 3.0

Ajouts de la communauté

AJOUTER
Afficher:
© 2014 Microsoft