Text Property
Collapse the table of content
Expand the table of content
This documentation is archived and is not being maintained.

RecognizedPhrase.Text Property

Returns the normalized text obtained by a recognition engine from audio input.

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

Property Value

A String instance containing the normalized text recognized from audio input.

The example below is a handler for displaying to a user interface the result of recognition events. The areas where the best candidate recognition text is displayed by using the Text on an instance of RecognizedPhrase are highlighted.

private void DisplayResult(EventArgs eventArgs) {
    //Make sure We handle different event types we support
    RecognitionResult result = null;
    if (null != (eventArgs as RecognitionEventArgs)) {
        result = (eventArgs as RecognitionEventArgs).Result;
    } else if (null != (eventArgs as EmulateRecognizeCompletedEventArgs)) {
        result = (eventArgs as EmulateRecognizeCompletedEventArgs).Result;
    }

    // In all cases, clear results, semantic XML, semantics tree, and alternates.
    _recognitionSmlBrowser.Navigate("about:blank");
    _semanticsTreeView.Nodes.Clear();
    //            _candidateList.Items.Clear();
    _candidateList.DataSource = null;
    _candidateList.DisplayMember = null;
    _phraseInfoLabel.Text = "";
    _bestCandidateTextBox.Text = "";

    if (result != null) {
        //Obtain result from RecognitionEventArg passed in.
        //Set Text color on the basis of the event type passed in.
        switch (eventArgs.GetType().ToString()) {
            case "Microsoft.Speech.Recognition.SpeechHypothesizedEventArgs":
                _bestCandidateTextBox.ForeColor = Color.Black;
                _bestCandidateTextBox.Text = result.Text;
                _phraseInfoLabel.Text = null;
                break;
            case "Microsoft.Speech.Recognition.SpeechRecognitionRejectedEventArgs":
                _bestCandidateTextBox.ForeColor = Color.OrangeRed;
                _bestCandidateTextBox.Text = "Unable to Recognize Input";
                _phraseInfoLabel.Text = String.Format("Rejected Phrase Information\n");
                Utils.DisplayBasicPhraseInfo(_phraseInfoLabel, result, _recognizer);
                Utils.DisplaySemanticsSML(_recognitionSmlBrowser, result);
                Utils.DisplaySemanticsTreeView(_semanticsTreeView, result.Semantics);
                break;
            case "Microsoft.Speech.Recognition.SpeechRecognizedEventArgs":
                _bestCandidateTextBox.ForeColor = Color.Green;
                _bestCandidateTextBox.Text = result.Text;
                _phraseInfoLabel.Text = String.Format("Recognized Phrase Information\n");

                Utils.DisplayBasicPhraseInfo(_phraseInfoLabel, result, _recognizer);
                Utils.DisplaySemanticsSML(_recognitionSmlBrowser, result);
                Utils.DisplaySemanticsTreeView(_semanticsTreeView, result.Semantics);
                break;
            case "Microsoft.Speech.Recognition.EmulateRecognizeCompletedEventArgs":
                _bestCandidateTextBox.ForeColor = Color.Green;
                _bestCandidateTextBox.Text = result.Text;
                _phraseInfoLabel.Text = String.Format("Recognized Phrase Information\n");
                Utils.DisplayBasicPhraseInfo(_phraseInfoLabel, result, _recognizer);
                Utils.DisplaySemanticsSML(_recognitionSmlBrowser, result);
                Utils.DisplaySemanticsTreeView(_semanticsTreeView, result.Semantics);
                break;

            default:
                _bestCandidateTextBox.ForeColor = Color.Black;
                break;
        }

        Utils.DisplayDataOnListBox(_candidateList, result.Alternates, "Text");

    }
}

All public static (Shared in Visual Basic) members of this type are thread-safe. Instance members are not guaranteed to be thread-safe.

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

Show:
© 2016 Microsoft