private void Mainevent_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { //System Username string Name = Environment.UserName; //Recognized Spoken words result is e.Result.Text string speech = e.Result.Text; //Debug_Livetxt.Text += "You said : " + e.Result.Text + "\n"; //Switch to e.Result.Text switch (speech) { //Greetings case "hello": Jarvis.SpeakAsync("hello " + Name); System.DateTime timenow = System.DateTime.Now; if (timenow.Hour >= 5 && timenow.Hour < 12) { Jarvis.SpeakAsync("Goodmorning " + Name); } if (timenow.Hour >= 12 && timenow.Hour < 18) { Jarvis.SpeakAsync("Good afternoon " + Name); } if (timenow.Hour >= 18 && timenow.Hour < 24) { Jarvis.SpeakAsync("Good evening " + Name); } if (timenow.Hour < 5) { Jarvis.SpeakAsync("Hello " + Name + ", you are still awake you should go to sleep, it's getting late"); } break; case "what time is it": System.DateTime now = System.DateTime.Now; string time = now.GetDateTimeFormats('t')[0]; Jarvis.SpeakAsync(time); break; case "what day is it": string day = "Today is," + System.DateTime.Now.ToString("dddd"); Jarvis.SpeakAsync(day); break; case "what is the date": case "what is todays date": string date = "The date is, " + System.DateTime.Now.ToString("dd MMM"); Jarvis.SpeakAsync(date); date = "" + System.DateTime.Today.ToString(" yyyy"); Jarvis.SpeakAsync(date); break; case "who are you": Jarvis.SpeakAsync("i am your personal assistant"); Jarvis.SpeakAsync("i can read email, weather report, i can search web for you, anything that you need like a personal assistant do, you can ask me question i will reply to you"); break; case "what is my name": Jarvis.SpeakAsync(Name); break; case "get all emails": case "get all inbox emails": EmailBtn.PerformClick(); AllEmails(); break; case "check for new emails": EmailBtn.PerformClick(); QEvent = "Checkfornewemails"; Jarvis.SpeakAsyncCancelAll(); EmailNum = 0; CheckEmails(); break; case "read the email": Jarvis.SpeakAsyncCancelAll(); try { Jarvis.SpeakAsync(MsgList[EmailNum]); } catch { Jarvis.SpeakAsync("There are no emails to read"); } break; case "next email": Jarvis.SpeakAsyncCancelAll(); try { EmailNum += 1; Jarvis.SpeakAsync(MsgList[EmailNum]); } catch { EmailNum -= 1; Jarvis.SpeakAsync("There are no further emails"); } break; case "previous email": Jarvis.SpeakAsyncCancelAll(); try { EmailNum -= 1; Jarvis.SpeakAsync(MsgList[EmailNum]); } catch { EmailNum += 1; Jarvis.SpeakAsync("There are no previous emails"); } break; //This is for text reader case "start reading": //ReadBtn.PerformClick(); if (tabControl1.SelectedIndex == 1) { Jarvis.SpeakAsync(Readtxt.Text); } if (tabControl1.SelectedIndex == 3) { Jarvis.SpeakAsync(convertedtxt.Text); } break; case "pause": //PauseBtn.PerformClick(); if (tabControl1.SelectedIndex == 1) { if (Jarvis.State == SynthesizerState.Speaking) { Jarvis.Pause(); } } if (tabControl1.SelectedIndex == 3) { if (Jarvis.State == SynthesizerState.Speaking) { Jarvis.Pause(); } } break; case "resume": PauseBtn.PerformClick(); if (tabControl1.SelectedIndex == 1) { if (Jarvis.State == SynthesizerState.Speaking) { Jarvis.Resume(); } } if (tabControl1.SelectedIndex == 3) { if (Jarvis.State == SynthesizerState.Speaking) { Jarvis.Resume(); } } break; case "stop": StopBtn.PerformClick(); break; case "open text file": Open_FileBtn.PerformClick(); break; //---untill here--- // case "change voice speed to minis two": Jarvis.Rate = -2; break; case "change voice speed to minis four": Jarvis.Rate = -4; break; case "change voice speed to minis six": Jarvis.Rate = -6; break; case "change voice speed to minis eight": Jarvis.Rate = -8; break; case "change voice speed to minis ten": Jarvis.Rate = -10; break; case "change voice speed back to normal": Jarvis.Rate = 0; break; case "change voice speed to two": Jarvis.Rate = 2; break; case "change voice speed to four": Jarvis.Rate = 4; break; case "change voice speed to six": Jarvis.Rate = 6; break; case "change voice speed to eight": Jarvis.Rate = 8; break; case "change voice speed to ten": Jarvis.Rate = 10; break; //For Media Player case "i want to add music": case "i want to add video": Jarvis.Speak("choose, music file from your drives"); Add_Music.PerformClick(); break; case "play music": case "play video": PlayBtn.PerformClick(); break; case "stop media player": MediaStopBtn.PerformClick(); break; case "fast forward": FastfarwardBtn.PerformClick(); break; case "fast reverse": FastReverseBtn.PerformClick(); break; case "media player resume": PlayBtn.PerformClick(); break; case "media player pause": PlayBtn.PerformClick(); break; case "media player previous": PreviousBtn.PerformClick(); break; case "media player next": NextBtn.PerformClick(); break; case "activate full screen mode": FullScreen.PerformClick(); break; case "exit full screen": FullScreen.PerformClick(); break; case "mute volume": case "volume down": Unmute_Volum.PerformClick(); break; case "unmute volume": case "volume up": Unmute_Volum.PerformClick(); break; //This is for news reader case "get bing news": GetBingNews(); break; //Untill here // //Weather grammar case "get weather report": Jarvis.SpeakAsync("ok, " + Name + " here is the weather report"); GetWeather(); break; } }