영어로 읽기

다음을 통해 공유


SpeechRecognizerUx.SpeechRecognizer property

 

The SpeechRecognizer property binds the SpeechRecognizerUx control to a SpeechRecognizer instance. This step is required for the SpeechRecognizerUx control to function.

Syntax

public SpeechRecognizerUx SpeechRecognizer(get; set;)

Property Value

SpeechRecognizerUx

The SpeechRecognizer instance to use.

Remarks

In JavaScript applications, you must set this property locally before calling the SpeechRecognizer.RecognizeSpeechToTextAsync() method. In C#/XAML, you may set the property once on a global SpeechRecognizer object and it will retain scope through the life of the application.

Example

The following code example creates a SpeechRecognizer instance, creates a SpeechRecognizerUx, binds them together, and adds the control to a UI container element named SpeechHostPanel.

using Microsoft.Bing.Speech;
using Microsoft.Bing.Speech.Xaml;
...
public MainPage()
{
    this.InitializeComponent();
    this.Loaded += MainPage_Loaded;
}

SpeechRecognizer SR;
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
    // Apply credentials from the Windows Azure Data Marketplace.
    var credentials = new SpeechAuthorizationParameters();
    credentials.ClientId = "<YOUR CLIENT ID>";
    credentials.ClientSecret = "<YOUR CLIENT SECRET>";

    // Initialize the speech recognizer.
    SR = new SpeechRecognizer("en-US", credentials);

    // Create a SpeechRecognizerUx control and bind it to 
    // the speech recognizer.
    var SpeechControl = new.SpeechRecognizerUx();
    SpeechControl.SpeechRecognizer = SR;

    // Add the control to the page.
    SpeechHostPanel.Children.Add(SpeechControl);
}

Requirements

Minimum Supported Client

Windows 8

Required Extensions

Bing.Speech

Namespace

Bing.Speech.Xaml