SpeechRecognizerUx class
The SpeechRecognizerUx class is a control that you can drop into a XAML or HTML page to display speech recognition UI.
The SpeechRecognizerUx class has the following members.
Name | Description |
|---|---|
Initializes a new instance of the SpeechRecognizerUx class. |
Name | Description |
|---|---|
A list of suggestions from the application developer, to be displayed at random in the Tips area of the SpeechRecognizerUx. | |
The SpeechRecognizer instance that the SpeechRecognizerUx acts on. |
By default, the SpeechRecognizerUx control is hidden until the SpeechRecognizer.RecognizeSpeechToTextAsync() method is called, starting the speech recognition session. The SpeechRecognizerUx control then becomes visible, and displays the following control UI.
A Go button that calls the SpeechRecognizer.StopListeningAndProcessAudio() method, which cuts off speech input and starts interpreting what has already been said. The Go button is available when the speech recognition session is in the "Listening" state.
A Cancel button that calls the SpeechRecognizer.RequestCancelOperation() method, which ends the speech recognition session and collapses the control. Clicking or tapping outside of the control also calls the RequestCancelOperation() method. The Cancel button replaces the Go button when the speech recognition session moves from "Listening" to "Thinking".
A volume animation to display the current volume level while the user is speaking.
Intermediate results, displayed in the left portion of the control when the user is speaking.
A text scramble animation to indicate when speech input is being interpreted.
Example
The following example creates a microphone button, a SpeechRecognizerUx control, and a results TextBlock in the markup page. Then, in the code behind, it creates a SpeechRecognizer instance, binds the SpeechRecognizerUx control to it, and provides a simple handler for the click event of the microphone button.
Example
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 and attach to control. SR = new SpeechRecognizer("en-US", credentials); SpeechControl.SpeechRecognizer = SR; } private async void SpeakButton_Click(object sender, RoutedEventArgs e) { try { // Start speech recognition. var result = await SR.RecognizeSpeechToTextAsync(); ResultText.Text = result.Text; } catch (System.Exception ex) { ResultText.Text = ex.Message; } }
When working with the SpeechRecognizerUx control in JavaScript, you must bind the control to the SpeechRecognizer in the local scope before calling RecognizeSpeechToTextAsync.
Requirements
Minimum Supported Client | Windows 8 |
Required Extensions | Bing.Speech |
Namespace |
The XAML AppBarButton element is only supported in Windows 8.1 or higher. To create a microphone button in Windows 8, you can use the MicrophoneAppBarButtonStyle, but you must first uncomment the style definition in StandardStyles.xaml. For more information, see How to: Add the Bing Speech Recognition Control to an application with the SpeechRecognizerUx class.