How to Use SpeechRecognizer in Windows Phone App using C#?

Published on October 1, 2013 by abundantcode

Filed under Windows Phone

Last modified October 1, 2013

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 0 (0 votes)

This article have been viewed 4036 times

Below is a sample code snippet demonstrating how to use the SpeechRecognizerUI in your Windows Phone app using C#.

Note that by default the speech recognizer API uses the default speech grammar accessed via the Microsoft cloud service and hence requires the network connection to be available for the below code snippet to work.

How to Use SpeechRecognizer in Windows Phone App using C#?

async private void Button_Click_1(object sender, RoutedEventArgs e)

{

SpeechRecognizerUI speech = new SpeechRecognizerUI();

await speech.Recognizer.PreloadGrammarsAsync();

SpeechRecognitionUIResult result = await speech.RecognizeWithUIAsync();

if (result.ResultStatus == SpeechRecognitionUIStatus.Succeeded)

{

MessageBox.Show(result.RecognitionResult.Text);

}

}

When the speech.RecognizeWithUIAsync is called, the SDK provides a dialog which will prompt the user to speak.

Once the SpeechRecognitionUIResult returns the SpeechRecognitionUIStatus.Succeeded, the RecognitionResult.Text will contain the text that was spoken.

0saves
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

1 Comment

  1. Nasir

    Sir I has a problem
    when i run the same code in my project (windows phone 8.1) it redirects me to App.xaml.cs class and points to

    private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
    {
    if (Debugger.IsAttached)
    {
    // An unhandled exception has occurred; break into the debugger
    Debugger.Break(); // this line
    }
    }
    can you please help me out ?
    thanks

    October 30, 2014 - 11:05 pm – Reply

Leave a Comment


x

You might be Interested in these Posts

C# and Lambda - Finding all the elements of an integer array less than 35

Here's a sample code snippet demonstrating how to find all the elements of an integer array that is ...

C# and LINQ - Finding all the elements of an integer array less than 35

Here's a sample code snippet demonstrating how to find all the elements of an integer array that is ...

How to get the CommandLine of the Current Application in C# ?

You might need to get the information that contains the commandline which is used to execute the cur...