Speech Recognition in Windows 8 (rather than having to hit a pesky button)

 
 In easy way to voice command your xaml applications.   Windows 8 will know all the commands it knows and then all the commands you add with:
            recognizer.LoadGrammar(grammar);
 
public void StartRecognitionCycle()
        {
List<string> grammarList = newList<string>() { “Call”, “Time”, “Information”, “Directions”, “Voice”, “Mute” };
Choices choices = newChoices(grammarList.ToArray());
GrammarBuilder grammarBuilder = newGrammarBuilder(choices);
Grammar grammar = newGrammar(grammarBuilder);
recognizer = new SpeechRecognizer();
            recognizer.LoadGrammar(grammar);
            recognizer.Enabled =true;
            recognizer.SpeechRecognized += newEventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
        }
      
public void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
switch (e.Result.Text.ToLower())
           {
    case“call”:
                   {
if(CellOn)
CallCommand.Execute();
break;
                   }
case“time”:
                   {
if (CellOn)
WatchCommand.Execute();
break;
                   }
              case“information”:
                   {
if (CellOn)
ReviewCommand.Execute();
break;
                   }
              case “directions”:
                   {
if (CellOn)
                       DirectionsAudioCommand.Execute();
break;
                   }
case“meeting”:
                {
if (CellOn)
                    MeetingReminderCommand.Execute();
                   break;
                }
             case “voice”:
                    {
                        CellOn = true;
           break;
                    }
               case “mute”:
                    {
                        CellOn = false;
                       break;
                    }
           }
        }
 
Keywords:
System.Speech.Recognition
.Net
Windows 8
WINRT
 
(From started from SQL demo here http://www.redmondpie.com/speech-recognition-in-a-c-wpf-application/)

Categories: Uncategorized

2 replies »

  1. hi, could you please provide some pointers around,what are these commands in switch statement? under which namespace they are, and what action then will do, on execute?
    Thanks a lot

    • Its anything you want to do, those were just Commands that linked into other applications.
      So if you have a command you can just add it to the commands like “LIGHTS” added to the grammar builder, then you call TurnLightsOn() method that would be a method you build.

      I have stuff I am doing for 6th sense/Single cell, but that wont be ready until http://www.leapMotion.com is released.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: