Share via


SpeechRecognitionResult.Text property

 

The Text property contains the recognized text of a speech recognition session.

Syntax

public string Text { get; }

Property Value

Type: System.String

The recognized text.

Remarks

When the SpeechRecognizer.RecognizeSpeechToTextAsync() method returns a SpeechRecognitionResult object, the Text property of the returned result represents the speech recognizer's best match for speech input by the user. Other possible interpretations are stored as additional SpeechRecognitionResult objects to be returned by the SpeechRecognitionResult.GetAlternates(int) method.

Example

The following example prints the result of a speech recognition session to a TextBox named ResultText.

// Initialize the SpeechRecognizer.
var credentials = new SpeechAuthorizationParameters();
credentials.ClientId = "<YOUR CLIENT ID>";
credentials.ClientSecret = "<YOUR CLIENT SECRET>";
SR = new SpeechRecognizer("en-US", credentials);

// Start speech recognition and display the result.
var result = await SR.RecognizeSpeechToTextAsync();
ResultText.Text = result.Text;
// Initialize the SpeechRecognizer.
var credentials = new Bing.Speech.SpeechAuthorizationParameters();
credentials.clientId = "<YOUR CLIENT ID>";
credentials.clientSecret = "<YOUR CLIENT SECRET>";
SR = new Bing.Speech.SpeechRecognizer("en-US", credentials);

// Start speech recognition and display the result.
SR.recognizeSpeechToTextAsync()
        .then(
            function (result) {
                if (typeof (result.text) == "string") {
                    document.getElementById('ResultText').innerHTML = result.text;
                }
            })

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 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