private void LeftBtn_Click(object sender, EventArgs e) { try { if (curr - 1 < 0) { curr = total - 1; } else { --curr; } StopBtn.PerformClick(); player.Close(); player.Open(filepaths[curr]); length = player.GetLength(); SeekSlider.Value = 0; PlayBtn.PerformClick(); player.Play(); } catch { } }
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; } }
private void Speechreco_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { string speech = e.Result.Text; try { switch (speech) { ///basic commands case "hello": case "hello martha": case "martha hello": martha.Speak("hello sir"); break; case "how are you": case "martha how are you": case "how are you martha": martha.Speak("Iam fine sir"); break; case "what is your name": martha.Speak("my name is martha iam an ai"); break; case "what is your gender": martha.Speak("i dont have a gender but my voice seems to be male"); break; case "are you there": case "martha are you there": case "are you there martha": martha.Speak("yes sir always ready"); break; case "exit": case "sleep": case "goodbye": case "goodbye martha": case "martha goodbye": case "martha bye": martha.Speak("good bye sir have a nice day"); Application.Exit(); break; ///opening commands case "open google": case "martha open google": case "open google martha": martha.Speak("opening google"); martha.Speak("loading"); Process.Start("chrome.exe", "http://www.google.com"); break; case "icognito": case "martha turn icognito": case "turn icognito": SendKeys.Send("^+n"); break; case "open youtube": case "martha open youtube": case "open youtube martha": martha.Speak("opening youtube"); martha.Speak("loading sir"); Process.Start("chrome.exe", "http://www.youtube.com"); break; case "open facebook": case "martha open facebook": case "open facebook martha": martha.Speak("opening facebook"); martha.Speak("loading"); Process.Start("chrome.exe", "http://www.facebook.com"); break; case "open instagram": case "martha open instagram": case "open instagram martha": martha.Speak("opening instagram"); martha.Speak("loading sir"); Process.Start("chrome.exe", "http://www.instagram.com"); break; case "open whatsapp": case "martha open whatsapp": case "open whatsapp martha": martha.Speak("opening whatsapp"); martha.Speak("loading"); Process.Start("chrome.exe", "http://www.whatsapp.com"); break; case "open amzon": case "martha open amazon": martha.Speak("opening amazon"); martha.Speak("loading"); martha.Speak("happy shoppoing sir"); Process.Start("chrome.exe", "http://www.amazon.in"); break; case "open flipkart": case "martha open flipkart": martha.Speak("opening flipkart"); martha.Speak("loading"); martha.Speak("happy shopping sir"); Process.Start("chrome.exe", "http://www.flipkart.com"); break; case "open notepad": case "martha open notepad": martha.Speak("opening notepad"); Process.Start("notepad.exe"); break; case "open wordpad": case "martha open wordpad": martha.Speak("opening wordpad"); Process.Start("wordpad.exe"); break; case "open cmd": case "martha open commandpromt": martha.Speak("opening commandpromt"); Process.Start("cmd.exe"); break; ///date and time case "what time is it": case "martha what is the time": martha.Speak(DateTime.Now.ToString("h:mm:tt")); break; case "what is the date": case "martha what is the date": martha.Speak(DateTime.Now.ToString("MM/dd/yyyy")); break; ///battery status ///cricket updates case "get cricket updates": martha.Speak("getting cricket updates"); Process.Start("chrome.exe", "http://www.cricbuzz.com"); break; ///Media player commands case "open playlist": martha.Speak("opening playlist"); martha.Speak("sir please select songs from your drives"); Add_Music.PerformClick(); break; case "play songs": martha.Speak("playing songs"); PlayBtn.PerformClick(); break; case "pause song": martha.Speak("pausing the song"); PlayBtn.PerformClick(); break; case "resume song": martha.Speak("resuimg the song"); PlayBtn.PerformClick(); break; case "stop song": martha.Speak("stoping the song"); MediaStopBtn.PerformClick(); break; case "play next song": martha.Speak("playing next song"); NextBtn.PerformClick(); break; case "play previous song": martha.Speak("playing previous song"); PreviousBtn.PerformClick(); break; case "forward song": martha.Speak("forwarding the song"); FastForwardBtn.PerformClick(); break; case "rewind song": martha.Speak("rewinding the song"); FastRewindBtn.PerformClick(); break; case "go fullscreen": martha.Speak("going full screen"); Full_Screen.PerformClick(); break; ///text reader case "open text files": OpenBtn.PerformClick(); break; case "read": ReadBtn.PerformClick(); break; case "pause": PauseBtn.PerformClick(); break; case "resume": PauseBtn.PerformClick(); break; case "stop": martha.SpeakAsyncCancelAll(); break; ///Gmail Reader case "get emails": case "get all emails": case "get all inbox emails": GmailReaderBtn.PerformClick(); AllEmails(); break; case "check for new emails": username = textBox1.Text; password = textBox2.Text; QEvent = "Checkfornewemails"; martha.SpeakAsyncCancelAll(); Emailnum = 0; CheckEmails(); break; case "read email": GmailReaderBtn.PerformClick(); martha.SpeakAsyncCancelAll(); try { martha.SpeakAsync(MsgList[Emailnum]); } catch { martha.SpeakAsync("there are no emails"); } break; case "next email": GmailReaderBtn.PerformClick(); martha.SpeakAsyncCancelAll(); try { Emailnum += 1; martha.SpeakAsync(MsgList[Emailnum]); } catch { Emailnum -= 1; martha.SpeakAsync("there are no further emails"); } break; case "previous email": GmailReaderBtn.PerformClick(); martha.SpeakAsyncCancelAll(); try { Emailnum -= 1; martha.SpeakAsync(MsgList[Emailnum]); } catch { Emailnum += 1; martha.SpeakAsync("there are no previous emails"); } break; case "stop reading gmails": { martha.SpeakAsyncCancelAll(); break; } ///pronounciation case "pronounce": { PronounceBtn.PerformClick(); break; } } } catch (Exception) { MessageBox.Show("MessageBox:martha is in pause state trun it to speaking state"); } }