private void button1_Click(object sender, EventArgs e) { cmd.add add = new cmd.add(); add.Show(); }
void recEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { string source = "server=remotemysql.com;user id=mzBXch0LSO;password =Qz0NXr8Dt8 ;database=mzBXch0LSO;allowuservariables=True"; MySqlConnection con = new MySqlConnection(source); con.Open(); // MessageBox.Show("Connected"); // string query = "select * from voice where id=" + int.Parse(txtID.Text); string query = "select * from voice"; MySqlCommand cmd = new MySqlCommand(query, con); MySqlDataReader dr = cmd.ExecuteReader(); /* if (dr.Read()) * { * String com = (dr["text"].ToString()); * String res = (dr["response"].ToString()); * // } * //con.Close(); * */ if (File.Exists("data.xml")) { data = XmlManager.XmlDataReader("data.xml"); string names = data.Name; } email em = new email(); Setting st = new Setting(); //String name = snamestore.Text; String name = data.Name; string spe = e.Result.Text; //String vc = voicelab.Text; if (snamestore.Text == "") { richTextBox1.Text += "\n Would you like to set your nick name"; richTextBox1.Text += "\n if yes.then sey 'change my name'"; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("\n please change your name, If you change you name then say change my name"); } /* * if (spe == "search for") * { * search = true; * richTextBox1.Text += "\n "+e.Result.Text; * voice.SelectVoiceByHints(VoiceGender.Female); * voice.SpeakAsync("what you want to search"); * * } * if (search) * { * Process.Start("https://www.google.com/search?q=" + spe); * search = false; * } */ // if (search == false) var soundsRoot = @"e:\music\wav"; var rand = new Random(); var soundFiles = Directory.GetFiles(soundsRoot, "*.wav"); var playSound = soundFiles[rand.Next(0, soundFiles.Length)]; System.Media.SoundPlayer player1 = new System.Media.SoundPlayer(playSound); string ai = e.Result.Text; note nt = new note(); //player1.Play() //String.IsNullOrEmpty(TextBoxCom.Text="hello") /* * case "": * richTextBox1.Text += "\n"+e.Result.Text; * voice.SelectVoiceByHints(VoiceGender.Female); * voice.SpeakAsync(""); * break; * * * richTextBox1.Text += "\n" + e.Result.Text; * voice.SelectVoiceByHints(VoiceGender.Female); * voice.SpeakAsync("hello sir"); * */ /* * if (ai == "") * { * * } * */ while (dr.Read()) { String com = (dr["text"].ToString()); String res = (dr["response"].ToString()); if (ai == com) { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync(res); } //voice.Volume = 100; } if (ai == "add command " || ai == Appname + " add command" || ai == "add my order") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("Okk sir. here it is"); cmd.add add = new cmd.add(); add.Show(); } if (ai == "show " + Appname) { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("hey sir"); } if (ai == "can you speak bangla") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("naa, ami baangla bolthee paari naa"); } if (ai == "tumar naam ki") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("amaar naam " + Appname); } if (ai == "hey " + Appname || ai == "hello " + Appname) { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("hey sir"); } if (ai == "show " + Appname) { this.WindowState = FormWindowState.Normal; } if (ai == "hide " + Appname) { this.WindowState = FormWindowState.Minimized; } if (ai == "hey jarvis") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("hello sir. But my name is " + Appname); } if (ai == "show setting") { Setting sg = new Setting(); sg.Show(); } if (ai == "add note" || ai == "show my note" || ai == "note") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("here is note"); nt.Show(); } if (ai == "roll a dice") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync(""); Random randomdice = new Random(); int randnumberdice = randomdice.Next(0, 7); voice.SpeakAsync(randnumberdice.ToString()); richTextBox1.Text += "\n" + randnumberdice.ToString(); } if (ai == "toss" || ai == "flip a coin") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync(""); string[] coin = { "Head", "Tale" }; Random random = new Random(); int randnumber = random.Next(0, coin.Length); //Convert.ToString(randnumber); if (randnumber == 0) { voice.SpeakAsync("Head"); richTextBox1.Text += "\n" + "Head"; } else if (randnumber == 1) { voice.SpeakAsync("Tale"); richTextBox1.Text += "\n" + "Tale"; } } if (ai == "close the browser") { richTextBox1.Text += "\n" + TextBoxCom.Text; voice.SelectVoiceByHints(VoiceGender.Female); webBrowser1.Hide(); voice.SpeakAsync("browser was closed"); } //..........................................music command............................... if (ai == "stop song") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync(""); if (playmusic == true) { player1.Stop(); voice.SpeakAsync("music stopped"); } else { richTextBox1.Text += "\n" + "music are not playing"; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("music are not playing"); } } if (ai == "play a music") { playmusic = true; richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("playing a music"); player1.Play(); } if (ai == "pause the music") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); player1.Stop(); voice.SpeakAsync("stopped"); } if (ai == "change the music") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("playing a music"); player1.Play(); } //..........................music end command............................... if (ai == "im fine") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("oh its great"); } if (ai == "google") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("what you want to search"); richTextBox1.Text += "\n" + "what you want to search"; search = true; } if (ai == "stop this") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("stoping"); richTextBox1.Text += "\n" + "stoped"; SendKeys.Send("%{F4}"); } if (ai == "developer facebook") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("opening developer facebook id"); richTextBox1.Text += "\n" + "opening developer facebook id"; Process.Start("http://facebook.com/sojebsikder"); } if (ai == "what time is it") { richTextBox1.Text += "\n" + e.Result.Text; richTextBox1.Text += "\n" + DateTime.Now.ToLongTimeString(); voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("Current time is " + DateTime.Now.ToLongTimeString()); richTextBox1.Text += "\n" + "Current time is " + DateTime.Now.ToLongTimeString(); time time = new time(DateTime.Now.ToLongTimeString()); time.Show(); } if (ai == "browser") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("hello im browser"); } if (ai == "show trick") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync(""); this.backgroundWorker1.RunWorkerAsync(); } if (ai == "download") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("enter url"); download dw = new download(); dw.Show(); } if (ai == "mail") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("here it is"); em.Show(); } if (ai == "open photoshop") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("photoshop opening"); Process.Start("photoshop"); } if (ai == "change my name") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("yeah sure"); st.Show(); } if (ai == "can i change my name") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("yeah sure."); //Setting st = new Setting(); st.Show(); } if (ai == "what is my name") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("your name is " + name); } if (ai == "hello") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("hello" + name); } //........... windows command....................................................... if (ai == "open remote") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("shutting down your computer"); Process.Start("C:\\Program Files (x86)\\Mouse Server\\MouseServer.exe"); } if (ai == "shutdown the computer") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("sorry my sir don't to do this"); //Process.Start("shutdown", "/s /t 0"); } if (ai == "restart the computer") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("restarting your computer"); Process.Start("shutdown", "/r /t 0"); } if (ai == "lock the computer") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("please wait "); LockWorkStation(); } if (ai == "what is my ip address") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("this is your ip address"); IPHostEntry host; string localIp = "?"; host = Dns.GetHostEntry(Dns.GetHostName()); foreach (IPAddress ip in host.AddressList) { localIp = ip.ToString(); richTextBox1.Text += "\n" + localIp; } } if (ai == "show command") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("here it is"); MessageBox.Show(""); } //end windows command.................................................... // open pogram...................................................................... if (ai == "open calculator") { Process.Start("calc"); } if (ai == "open microsoft word") { Process.Start("winword"); } if (ai == "open microsoft excel") { Process.Start("excel"); } if (ai == "open microsoft powerpoint") { Process.Start("powerpoint"); } if (ai == "open paint") { Process.Start("mspaint"); } if (ai == "notepad") { Process.Start("notepad"); } if (ai == "open chrome") { Process.Start("chrome"); } //end open program........................................................... //..........Conversation................................................................. if (ai == "im good") { // MessageBox.Show("hello im computer"); richTextBox1.Text += "\nhello sojeb"; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("it's pleasure to me"); } if (ai == "say hello") { // MessageBox.Show("hello im computer"); richTextBox1.Text += "\nhello sojeb"; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("hello sojib"); } if (ai == "what is your name") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("my name is " + Appname); } if (ai == "when you are created") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("in 19 November 2018"); } if (ai == "can you change your voice") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("hmm. no"); } if (ai == "im also good") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("this is pleasure to me"); } if (ai == "how are you" || ai == "what about you") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("im great, what about you"); } if (ai == "why you dont have any feel") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("because im a robot created by programming language"); } if (ai == "how do you feel") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("i have no feel"); } if (ai == "who are you") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("im " + Appname + ", your personal assistance"); } if (ai == "what can you do") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("this is can i do for you"); richTextBox1.Text += "\n1. "; } if (ai == "what language are used to create you") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("c#"); } if (ai == "who created you") { richTextBox1.Text += "\n" + e.Result.Text; voice.SelectVoiceByHints(VoiceGender.Female); voice.SpeakAsync("i was created by sojib sikder"); } if (ai == "close the application") { richTextBox1.Text += "\n" + e.Result.Text; richTextBox1.Text += "\n Closing the application..."; Application.Exit(); } // richTextBox1.Text += e.Result.Text; //.........................End Conversation.......................................................... // search = true; /* * else * * { * search = true; * Process.Start("https://www.google.com/search?q=" + spe); * search = false; * } * * //} * // else * // { * // Process.Start("chrome"); * //} * // richTextBox1.Text += e.Result.Text.ToString() + Environment.NewLine; * /* foreach (var process in Process.GetProcessesByName(e.Result.Text)) * { * * process.Kill(); * * * } * */ // } // con.Close(); }