Click here to Skip to main content
15,891,513 members
Articles / Programming Languages / C#
Tip/Trick

SpeechRecognition Windows Phone 8 c#

Rate me:
Please Sign up or sign in to vote.
4.50/5 (4 votes)
6 Aug 2014CPOL 10.1K   4   1
The easy way to use speech Recognition by converting Speech to Text

Introduction

Sometimes , we don't want to type some words by keyboard in the App , if you got tired and you want just speech so here is the solution.

Using the code

First of all , you need to add the Capability ID_CAP_SPEECH_RECOGNITION on the Manifest file.

we create an instance of  SpeechRecognitionResult.

SpeechRecognitionResult recoResult = await myRecognizer.RecognizeAsync();

The speech will be Translated by bing. if it recognise what you said as the correct language it will return it as a Text else it will return an erreur.

            try
            
              {
               
               

                // Check to see if speech input was rejected and prompt the user.
                if (recoResult.TextConfidence == SpeechRecognitionConfidence.Rejected)
                {
                   test  = "Sorry, didn't catch that. \n\nSay again.";
                 
                }

                // Check to see if speech input was recognized with low confidence and prompt the                 // user to speak again.
                else if (recoResult.TextConfidence == SpeechRecognitionConfidence.Low)
                {
                    test  = "Not sure what you said. \n\nSay again.";

                }

                // Check to see if speech input was recognized and confirm the result.
                else if (recoResult.TextConfidence == SpeechRecognitionConfidence.High ||
                      recoResult.TextConfidence == SpeechRecognitionConfidence.Medium)
                {

                        MessageBox.Show(recoResult.Text);
                }
              
            }
            catch (Exception ee)
            {

               //erreur
            }

 

You just implement this code , you should change the language on the Settings on you device.

History

You can know create many usefull Apps , what are you waiting for ! ;)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Junior) Microsoft Student Partners
Tunisia Tunisia
I study Software Engineering , 23 years old , I'm motivated with all Technologies of Microsoft.
Since I have been in the Community of Microsoft as Microsoft Student Partners, I developped many apps on the platform Windows and Phone. Now , it's time to share what I learn here and I'am ready to help Everyone.
You can contact me at any time (anisderbel@outlook.com)
This is a Organisation

9 members

Comments and Discussions

 
SuggestionSome improvements Pin
Wendelius6-Aug-14 19:04
mentorWendelius6-Aug-14 19:04 
While I appreciate your efforts to contribute, I feel that this tip doesn't give much additional information compared to the official documentation: SpeechRecognitionResult.TextConfidence property[^]

Defining a use case and adding more code and explanation based on that would greatly improve the tip.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.