For this sort of thing, you can pull the target phrase from the RecognizedPhrase.Words
property. Since the first 3 words of the result.text
are going to be "Search Google for", result.words[3]..results.words[result.words.count-1]
will have the phrase to search for.
Concatenate them together and off you go.
To support multiple actions, use the Grammar.Name
property to tell which command you want to run.
void Engine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
txtSpeech.Text = e.Result.Text;
ExtractKeywords(e.Result.Text);
if (e.Result.Grammar.Name.Equals("Google Search"))
{
OpenApp("www.google.com", result);
}
else if (e.Result.Grammar.Name.Equals("StackOverflow Search"))
{
OpenApp("www.stackoverflow.com", result);
}
// etc...
}