I would like to add, that whenever it recognizes 'search X' it is going to search for 'X', but i don't know how i have to add that to the grammar, or how to do such a thing with my switch statement.
private void Form1_Load(object sender, EventArgs e)
{
Choices commands = new Choices();
commands.Add(new string[] { "hello", "start chrome", "search" });
GrammarBuilder gBuilder = new GrammarBuilder();
gBuilder.Append(commands);
gBuilder.Culture = new System.Globalization.CultureInfo("en-GB");
Grammar grammar = new Grammar(gBuilder);
recEngine.LoadGrammarAsync(grammar);
recEngine.SetInputToDefaultAudioDevice();
recEngine.SpeechRecognized += RecEngine_SpeechRecognized;
}
private void RecEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
switch (e.Result.Text)
{
case "hello":
synthesizer.SpeakAsync("Hello! How are you doing today?");
break;
case "start chrome":
Process.Start("http://www.google.com");
break;
case "search":
SearchChrome("search");
break;
}
}
static void SearchChrome(string searchterm)
{
Process.Start("https://www.google.com/search?q=" + searchterm);
}
So i'd like to add to my grammar "Search X", and to my cases "Search X", with it searching for whatever X is.
Thanks in advance!