我正在制作自己的 jarvis 程序,当我说“搜索”+ 某物时,我想打开 Google 并搜索“某物”。这是我的代码...(我没有全部粘贴)
private void Form1_Load(object sender, EventArgs e)
{
_recognizer.SetInputToDefaultAudioDevice();
_recognizer.LoadGrammar(new Grammar(new GrammarBuilder(new Choices(File.ReadAllLines(@"C:\Users\Cpyros\Desktop\lefteris\Commands.txt")))));
_recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(_recognizer_SpeechRecognized);
_recognizer.RecognizeAsync(RecognizeMode.Multiple);
}
void _recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
int ranNum = rnd.Next(1, 10);
string speech = e.Result.Text;
switch (speech)
{
//GREETINGS
case "hello":
case "hello jarvis":
if (ranNum < 6) { JARVIS.Speak("Hello sir"); }
else if (ranNum > 5) { JARVIS.Speak("Hi"); }
break;
case "goodbye":
case "goodbye jarvis":
case "close":
case "close jarvis":
JARVIS.Speak("Until next time");
Close();
break;
case "jarvis":
if (ranNum < 5) { QEvent = ""; JARVIS.Speak("Yes sir"); }
else if (ranNum > 4) { QEvent = ""; JARVIS.Speak("Yes?"); }
break;
//WEBSITES
case "open facebook":
System.Diagnostics.Process.Start("http://www.facebook.com");
break;
case "open google":
Process.Start("https://www.google.gr/?gws_rd=cr");
JARVIS.Speak("Okay sir");
System.Windows.Forms.SendKeys.SendWait("^%.");
break;
here i want to add a case like "search for" + the thing i want to search...
有任何想法吗?