Exemple #1
0
        void Default_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            int    ranNum        = rnd.Next(1, 10);
            string checkinternet = NetworkInterface.GetIsNetworkAvailable().ToString();

            checkinternet.Replace("True", "Connected");
            checkinternet.Replace("False", "Disconnected");
            string speech = e.Result.Text;

            switch (speech)
            {
            //GREETINGS
            case "Hello":
            case "Hello Aivi":
                now = DateTime.Now;
                if (now.Hour >= 5 && now.Hour < 12)
                {
                    Aivi.SpeakAsync("Goodmorning " + Settings.Default.User);
                }
                if (now.Hour >= 12 && now.Hour < 18)
                {
                    Aivi.SpeakAsync("Good afternoon " + Settings.Default.User);
                }
                if (now.Hour >= 18 && now.Hour < 24)
                {
                    Aivi.SpeakAsync("Good evening " + Settings.Default.User);
                }
                if (now.Hour < 5)
                {
                    Aivi.SpeakAsync("Hello " + Settings.Default.User + ", it's getting late");
                }
                break;

            case "Goodbye":
            case "Goodbye Aivi":
            case "Close Aivi":
                Aivi.Speak("Farewell");
                Close();
                break;

            case "Aivi":
                ranNum = rnd.Next(1, 5);
                if (ranNum == 1)
                {
                    QEvent = ""; Aivi.SpeakAsync("Yes sir");
                }
                else if (ranNum == 2)
                {
                    QEvent = ""; Aivi.SpeakAsync("Yes?");
                }
                else if (ranNum == 3)
                {
                    QEvent = ""; Aivi.SpeakAsync("How may I help?");
                }
                else if (ranNum == 4)
                {
                    QEvent = ""; Aivi.SpeakAsync("How may I be of assistance?");
                }
                break;

            case "What's my name?":
                Aivi.SpeakAsync(Settings.Default.User);
                break;

            case "Who are you":
                Aivi.SpeakAsync("My name is Aivi. I m your personal Assistant");
                break;

            case "introduce yourself":
            case "Aivi introduce yourself":
                Aivi.SpeakAsync("Ok.  My name is Aivi. I'm an artificial intelligence softwre. designed by my masters to help u with your device.");
                Aivi.SpeakAsync("i can read email, weather report, i can search web for you, i can fix and tell you about your appointments, anything that you need like a personal assistant do, you can ask me question i will reply to you.For now my capability is limited.But i can help you with almost everithing");

                break;



            case "Stop talking":
                Aivi.SpeakAsyncCancelAll();
                ranNum = rnd.Next(1, 5);
                if (ranNum == 5)
                {
                    Aivi.Speak("fine");
                }
                break;

            //CONDITION OF DAY
            case "What time is it":
                now = DateTime.Now;
                string time = now.GetDateTimeFormats('t')[0];
                Aivi.SpeakAsync(time);
                break;

            case "What day is it":
                Aivi.SpeakAsync(DateTime.Today.ToString("dddd"));
                break;

            case "Whats the date":
            case "Whats todays date":
                Aivi.SpeakAsync(DateTime.Today.ToString("dd-MM-yyyy"));
                break;

            case "Hows the weather":
            case "todays weather":
            case "tell me about the weather":
            case "how is the weather today":
            case "Whats it like outside":
                GetWeather("");
                if (QEvent == "connected")
                {
                    Aivi.SpeakAsync("The weather in " + GetWeather("city") + " is " + GetWeather("text"));
                    Aivi.SpeakAsync(" at " + GetWeather("temp") + " degrees.");
                    Aivi.SpeakAsync("There is a humidity of " + GetWeather("humidity"));
                    Aivi.SpeakAsync(" and a windspeed of " + GetWeather("speed") + " miles per hour");
                    Aivi.SpeakAsync("Sunrise at" + GetWeather("sunrise") + "And Sunset at" + GetWeather("sunset"));
                }
                else if (QEvent == "failed")
                {
                    Aivi.SpeakAsync("I could not access the server, are you sure you have the right W O E I D?");
                }

                break;

            case "What will tomorrow be like":
            case "Whats tomorrows forecast":
            case "Whats tomorrow like":
                GetWeather("");
                if (QEvent == "connected")
                {
                    Aivi.SpeakAsync("Tomorrows forecast is " + GetWeather("tfcond") + " with a high of " + GetWeather("tfhigh") + " and a low of " + GetWeather("tflow"));
                }
                else if (QEvent == "failed")
                {
                    Aivi.SpeakAsync("I could not connect to the weather service");
                }
                break;

            case "Whats the temperature":
            case "Whats the temperature outside":
                GetWeather("");

                if (QEvent == "connected")
                {
                    Aivi.SpeakAsync(GetWeather("temp") + " degrees");
                }

                else if (QEvent == "failed")
                {
                    Aivi.SpeakAsync("I could not connect to the weather service");
                }
                break;



            case "where is my location":
            case "my location":
            case "whire i am":
                GetWeather("");

                if (QEvent == "connected")
                {
                    Aivi.SpeakAsync("You are in " + GetWeather("city") + "city");
                }

                else if (QEvent == "failed")
                {
                    Aivi.SpeakAsync("I could not connect to the weather service");
                }
                break;



            //face recognization

            case "open fgace recognization":
                FaceRecognization FR = new FaceRecognization();
                FR.Show();
                break;

            //APPLICATION COMMANDS
            case "Switch Window":
                SendKeys.Send("%{TAB " + count + "}");
                count += 1;
                break;

            case "Close window":
                SendKeys.Send("%{F4}");
                break;

            case "Out of the way":
                if (WindowState == FormWindowState.Normal)
                {
                    WindowState = FormWindowState.Minimized;
                    Aivi.SpeakAsync("My apologies");
                }
                break;

            case "Come back":
                if (WindowState == FormWindowState.Minimized)
                {
                    Aivi.SpeakAsync("Alright");
                    WindowState = FormWindowState.Normal;
                }
                break;

            case "Show default commands":
                string[] defaultcommands = (File.ReadAllLines(@"Default Commands.txt"));
                Aivi.SpeakAsync("Very well");
                CommandModule.Items.Clear();
                CommandModule.SelectionMode = SelectionMode.None;
                CommandModule.Visible       = true;
                foreach (string command in defaultcommands)
                {
                    CommandModule.Items.Add(command);
                }
                CommandModule.Items.Add("Aivi Come Back Online");
                break;

            case "Show shell commands":
                Aivi.SpeakAsync("Here we are");
                CommandModule.Items.Clear();
                CommandModule.SelectionMode = SelectionMode.None;
                CommandModule.Visible       = true;
                foreach (string command in ArrayShellCommands)
                {
                    CommandModule.Items.Add(command);
                }
                break;

            case "Show social commands":
                Aivi.SpeakAsync("Alright");
                CommandModule.Items.Clear();
                CommandModule.SelectionMode = SelectionMode.None;
                CommandModule.Visible       = true;
                foreach (string command in ArraySocialCommands)
                {
                    CommandModule.Items.Add(command);
                }
                break;

            case "Show web commands":
                Aivi.SpeakAsync("Ok");
                CommandModule.Items.Clear();
                CommandModule.SelectionMode = SelectionMode.None;
                CommandModule.Visible       = true;
                foreach (string command in ArrayWebCommands)
                {
                    CommandModule.Items.Add(command);
                }
                break;

            case "Show Music Library":
                CommandModule.SelectionMode = SelectionMode.One;
                CommandModule.Items.Clear();
                CommandModule.Visible = true;
                i = 0;
                foreach (string file in FileLocations)
                {
                    if (file.Contains(".mp3") || file.Contains(".m4a") || file.Contains(".wav"))
                    {
                        CommandModule.Items.Add(FileNames[i]); i += 1;
                    }
                    else
                    {
                        i += 1;
                    }
                }
                QEvent = "Play music file";
                break;

            case "Show Video Library":
                CommandModule.SelectionMode = SelectionMode.One;
                CommandModule.Items.Clear();
                CommandModule.Visible = true;
                i = 0;
                foreach (string file in FileLocations)
                {
                    if (file.Contains(".mp4") || file.Contains(".avi") || file.Contains(".mkv"))
                    {
                        CommandModule.Items.Add(FileNames[i]); i += 1;
                    }
                    else
                    {
                        i += 1;
                    }
                }
                QEvent = "Play video file";
                break;

            case "Show Email List":
                CommandModule.SelectionMode = SelectionMode.One;
                CommandModule.Items.Clear();
                CommandModule.Visible = true;
                foreach (string line in MsgList)
                {
                    CommandModule.Items.Add(line);
                }
                QEvent = "Checkfornewemails";
                break;

            case "Show listbox":
                CommandModule.Visible = true;
                break;

            case "Hide listbox":
                CommandModule.Visible = false;
                break;


            case "Open Music Player":
            case "Music Player":
                MediaPlayer Mp = new MediaPlayer();
                Mp.Show();
                break;

            //SHUTDOWN RESTART LOG OFF

            /* case "Shutdown":
             *   if (ShutdownTimer.Enabled == false)
             *   {
             *       QEvent = "shutdown";
             *       Aivi.SpeakAsync("I will shutdown shortly");
             *       lblTimer.Visible = true;
             *       ShutdownTimer.Enabled = true;
             *   }
             *   break;
             *
             * case "Log off":
             *   if (ShutdownTimer.Enabled == false)
             *   {
             *       QEvent = "logoff";
             *       Aivi.SpeakAsync("Logging off");
             *       lblTimer.Visible = true;
             *       ShutdownTimer.Enabled = true;
             *   }
             *   break;
             *
             * case "Restart":
             *  if (ShutdownTimer.Enabled == false)
             *  {
             *      QEvent = "restart";
             *      Aivi.SpeakAsync("I will be back shortly");
             *      lblTimer.Visible = true;
             *      ShutdownTimer.Enabled = true;
             *  }
             *  break; */

            case "Abort":
                if (ShutdownTimer.Enabled == true)
                {
                    timer                 = 31;
                    lblTimer.Text         = timer.ToString();
                    ShutdownTimer.Enabled = false;
                    lblTimer.Visible      = false;
                }
                break;

            //OTHER
            case "I want to add custom commands":
            case "I want to add a custom command":
            case "I want to add a command":
                CustomSettings customwindow = new CustomSettings();
                customwindow.Show();
                break;

            case "Update commands":
                Aivi.SpeakAsync("This may take a few seconds");
                _recognizer.UnloadGrammar(shellcommandgrammar);
                _recognizer.UnloadGrammar(webcommandgrammar);
                _recognizer.UnloadGrammar(socialcommandgrammar);
                ArrayShellCommands  = File.ReadAllLines(scpath);
                ArrayShellResponse  = File.ReadAllLines(srpath);
                ArrayShellLocation  = File.ReadAllLines(slpath);
                ArrayWebCommands    = File.ReadAllLines(webcpath);
                ArrayWebResponse    = File.ReadAllLines(webrpath);
                ArrayWebURL         = File.ReadAllLines(weblpath);
                ArraySocialCommands = File.ReadAllLines(socpath);
                ArraySocialResponse = File.ReadAllLines(sorpath);
                try
                { shellcommandgrammar = new Grammar(new GrammarBuilder(new Choices(ArrayShellCommands))); _recognizer.LoadGrammar(shellcommandgrammar); }
                catch
                { Aivi.SpeakAsync("I've detected an in valid entry in your shell commands, possibly a blank line. Shell commands will cease to work until it is fixed."); }
                try
                { webcommandgrammar = new Grammar(new GrammarBuilder(new Choices(ArrayWebCommands))); _recognizer.LoadGrammar(webcommandgrammar); }
                catch
                { Aivi.SpeakAsync("I've detected an in valid entry in your web commands, possibly a blank line. Web commands will cease to work until it is fixed."); }
                try
                { socialcommandgrammar = new Grammar(new GrammarBuilder(new Choices(ArraySocialCommands))); _recognizer.LoadGrammar(socialcommandgrammar); }
                catch
                { Aivi.SpeakAsync("I've detected an in valid entry in your social commands, possibly a blank line. Social commands will cease to work until it is fixed."); }
                Aivi.SpeakAsync("All commands updated");
                break;


            case "Refresh libraries":
                Aivi.SpeakAsync("Loading libraries");
                try { _recognizer.UnloadGrammar(Allfiles); }
                catch { Aivi.SpeakAsync("Previous grammar was invalid"); }
                QEvent = "ReadDirectories";
                ReadDirectories();
                break;

            case "Change video directory":
                Aivi.SpeakAsync("Please choose a directory to load your video files");
                VideoFBD.SelectedPath = Settings.Default.VideoFolder;
                VideoFBD.Description  = "Please select your video directory";
                DialogResult videoresult = VideoFBD.ShowDialog();
                if (videoresult == DialogResult.OK)
                {
                    Settings.Default.VideoFolder = VideoFBD.SelectedPath;
                    Settings.Default.Save();
                    QEvent = "ReadDirectories";
                    ReadDirectories();
                }
                break;

            case "Change music directory":
                Aivi.SpeakAsync("Please choose a directory to load your music files");
                MusicFBD.SelectedPath = Settings.Default.MusicFolder;
                MusicFBD.Description  = "Please select your music directory";
                DialogResult musicresult = MusicFBD.ShowDialog();
                if (musicresult == DialogResult.OK)
                {
                    Settings.Default.MusicFolder = MusicFBD.SelectedPath; Settings.Default.Save();
                    QEvent = "ReadDirectories";
                    ReadDirectories();
                }
                break;

            case "Stop listening":
                Aivi.SpeakAsync("I will await further commands");
                _recognizer.RecognizeAsyncCancel();
                startlistening.RecognizeAsync(RecognizeMode.Multiple);
                changelisten = true;
                break;

            //GMAIL NOTIFICATION
            case "Check for new emails":
                QEvent = "Checkfornewemails";
                Aivi.SpeakAsyncCancelAll();
                EmailNum = 0;
                CheckForEmails();
                break;

            case "Open the email":
                try
                {
                    Aivi.SpeakAsyncCancelAll();
                    Aivi.SpeakAsync("Very well");
                    System.Diagnostics.Process.Start(MsgLink[EmailNum]);
                }
                catch { Aivi.SpeakAsync("There are no emails to read"); }
                break;
            // websearch


            case "I WANT TO SEARCH SOMETHING":
            case "search for":
                string Speech = e.Result.Text;
                Aivi.SpeakAsync("what do you want to search");


                //if (Speech == "I WANT TO SEARCH SOMETHING")

                /* {
                 *    QEvent = Speech;
                 *    Aivi.SpeakAsync("what do you want to search");
                 *    Speech = string.Empty;
                 * }*/

                if (Speech != string.Empty)
                {
                    System.Diagnostics.Process.Start("http://google.com/search?q=" + Speech);
                    QEvent = string.Empty;

                    int Num = rnd.Next(1, 4);
                    if (Num == 1)
                    {
                        Aivi.SpeakAsync("Alright, I am searching " + Speech + " in google");
                    }
                    else if (Num == 2)
                    {
                        Aivi.SpeakAsync("ok sir, I am searching " + Speech);
                    }
                    else if (Num == 3)
                    {
                        Aivi.SpeakAsync("Alright, I am searching ");
                    }
                    Speech = string.Empty;
                }
                break;



            case "Read the email":
                Aivi.SpeakAsyncCancelAll();
                try
                {
                    Aivi.SpeakAsync(MsgList[EmailNum]);
                }
                catch { Aivi.SpeakAsync("There are no emails to read"); }
                break;

            case "Next email":
                Aivi.SpeakAsyncCancelAll();
                try
                {
                    EmailNum += 1;
                    Aivi.SpeakAsync(MsgList[EmailNum]);
                }
                catch { EmailNum -= 1; Aivi.SpeakAsync("There are no further emails"); }
                break;

            case "Previous email":
                Aivi.SpeakAsyncCancelAll();
                try
                {
                    EmailNum -= 1;
                    Aivi.SpeakAsync(MsgList[EmailNum]);
                }
                catch { EmailNum += 1; Aivi.SpeakAsync("There are no previous emails"); }
                break;

            case "Clear email list":
                Aivi.SpeakAsyncCancelAll();
                MsgList.Clear(); MsgLink.Clear(); CommandModule.Items.Clear(); EmailNum = 0; Aivi.SpeakAsync("Email list has been cleared");
                break;
            }
        }
Exemple #2
0
        void Default_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            int    ranNum;
            string speech = e.Result.Text;

            switch (speech)
            {
            //GREETINGS
            case "Hello":
            case "Hello Jarvis":
                now = DateTime.Now;
                if (now.Hour >= 5 && now.Hour < 12)
                {
                    JARVIS.SpeakAsync("Goodmorning " + Settings.Default.User);
                }
                if (now.Hour >= 12 && now.Hour < 18)
                {
                    JARVIS.SpeakAsync("Good afternoon " + Settings.Default.User);
                }
                if (now.Hour >= 18 && now.Hour < 24)
                {
                    JARVIS.SpeakAsync("Good evening " + Settings.Default.User);
                }
                if (now.Hour < 5)
                {
                    JARVIS.SpeakAsync("Hello " + Settings.Default.User + ", it's getting late");
                }
                break;

            case "Goodbye":
            case "Goodbye Jarvis":
            case "Close Jarvis":
            case "go offline":
                JARVIS.Speak("Farewell");
                Close();
                break;

            case "Jarvis":
            case "hey":
                ranNum = rnd.Next(1, 5);
                if (ranNum == 1)
                {
                    QEvent = ""; JARVIS.SpeakAsync("Yes sir");
                }
                else if (ranNum == 2)
                {
                    QEvent = ""; JARVIS.SpeakAsync("Yes?");
                }
                else if (ranNum == 3)
                {
                    QEvent = ""; JARVIS.SpeakAsync("How may I help?");
                }
                else if (ranNum == 4)
                {
                    QEvent = ""; JARVIS.SpeakAsync("How may I be of assistance?");
                }
                break;

            case "What's my name?":
                JARVIS.SpeakAsync(Settings.Default.User);
                break;

            case "Stop talking":
            case "Shut up":
            case "be quiet":
            case "not now":
                JARVIS.SpeakAsyncCancelAll();
                ranNum = rnd.Next(1, 5);
                if (ranNum == 5)
                {
                    JARVIS.Speak("fine");
                }
                break;

            //CONDITION OF DAY
            case "What time is it":
            case "time check":
            case "What is the time":
            case "give me the time":
            case "check the time for me":
            case "check the time":
            case "check the clock":

                now = DateTime.Now;
                string time = now.GetDateTimeFormats('t')[0];
                JARVIS.SpeakAsync(time);
                break;

            case "What day is it":
            case "What day of the week is it":
            case "Which day is today":
            case "What weekday is it":
                JARVIS.SpeakAsync(DateTime.Today.ToString("dddd"));
                break;

            case "Whats the date":
            case "Whats todays date":
            case "What day of the month is it":
                JARVIS.SpeakAsync(DateTime.Today.ToString("dd-MM-yyyy"));
                break;

            case "Hows the weather":
            case "Whats the weather like":
            case "Whats it like outside":
            case "Weather report":
            case "Whats the weather status":

                GetWeather();
                if (QEvent == "connected")
                {
                    JARVIS.SpeakAsync("The weather in " + Town + " is " + Condition + " at " + Temperature + " degrees. There is a humidity of " + Humidity + " and a windspeed of " + WinSpeed + " miles per hour");
                }
                else if (QEvent == "failed")
                {
                    JARVIS.SpeakAsync("I seem to be having a bit of trouble connecting to the server. would you like me to run a diagnostic?");
                }
                break;

            case "What will tomorrow be like":
            case "Whats tomorrows forecast":
            case "Whats the forcast":
            case "Whats tomorrow like":
                GetWeather();
                if (QEvent == "connected")
                {
                    JARVIS.SpeakAsync("Tomorrows forecast is " + TFCond + " with a high of " + TFHigh + " and a low of " + TFLow);
                }
                else if (QEvent == "failed")
                {
                    JARVIS.SpeakAsync("I could not access the server.");
                }
                break;

            case "Whats the temperature":
            case "Whats the temperature outside":
                GetWeather();
                if (QEvent == "connected")
                {
                    JARVIS.SpeakAsync(Temperature + " degrees");
                }
                else if (QEvent == "failed")
                {
                    JARVIS.SpeakAsync("I could not connect to the weather service");
                }
                break;

            //APPLICATION COMMANDS
            case "Switch Window":
                SendKeys.Send("%{TAB " + count + "}");
                count += 1;
                break;

            case "Close ":
                SendKeys.Send("{{CTRL}}W");
                JARVIS.SpeakAsync("closing");
                break;

            case "Out of the way":
            case "offscreen":
                if (WindowState == FormWindowState.Normal)
                {
                    WindowState = FormWindowState.Minimized;
                    JARVIS.SpeakAsync("My apologies");
                }
                break;

            case "Come back":
            case "onscreen":
                if (WindowState == FormWindowState.Minimized)
                {
                    JARVIS.SpeakAsync("onscreen sir");
                    WindowState = FormWindowState.Normal;
                }
                break;

            case "Show default commands":
                string[] defaultcommands = (File.ReadAllLines(@"Default Commands.txt"));
                JARVIS.SpeakAsync("Very well");
                lstCommands.Items.Clear();
                lstCommands.SelectionMode = SelectionMode.None;
                lstCommands.Visible       = true;
                foreach (string command in defaultcommands)
                {
                    lstCommands.Items.Add(command);
                }
                lstCommands.Items.Add("JARVIS Come Back Online");
                break;

            case "Show shell commands":
                JARVIS.SpeakAsync("Here we are");
                lstCommands.Items.Clear();
                lstCommands.SelectionMode = SelectionMode.None;
                lstCommands.Visible       = true;
                foreach (string command in ArrayShellCommands)
                {
                    lstCommands.Items.Add(command);
                }
                break;

            case "Show social commands":
                JARVIS.SpeakAsync("Alright");
                lstCommands.Items.Clear();
                lstCommands.SelectionMode = SelectionMode.None;
                lstCommands.Visible       = true;
                foreach (string command in ArraySocialCommands)
                {
                    lstCommands.Items.Add(command);
                }
                break;

            case "Show web commands":
                JARVIS.SpeakAsync("here are the web commands sir");
                lstCommands.Items.Clear();
                lstCommands.SelectionMode = SelectionMode.None;
                lstCommands.Visible       = true;
                foreach (string command in ArrayWebCommands)
                {
                    lstCommands.Items.Add(command);
                }
                break;

            case "Show Music Library":
                JARVIS.SpeakAsync("your music library sir");
                lstCommands.SelectionMode = SelectionMode.One;
                lstCommands.Items.Clear();
                lstCommands.Visible = true;
                i = 0;
                foreach (string file in FileLocations)
                {
                    if (file.Contains(".mp3") || file.Contains(".m4a") || file.Contains(".wav"))
                    {
                        lstCommands.Items.Add(FileNames[i]); i += 1;
                    }
                    else
                    {
                        i += 1;
                    }
                }
                QEvent = "Play music ";
                break;

            case "Show Video Library":
                JARVIS.SpeakAsync("you Video library is loaded sir");
                lstCommands.SelectionMode = SelectionMode.One;
                lstCommands.Items.Clear();
                lstCommands.Visible = true;
                i = 0;
                foreach (string file in FileLocations)
                {
                    if (file.Contains(".mp4") || file.Contains(".avi") || file.Contains(".mkv"))
                    {
                        lstCommands.Items.Add(FileNames[i]); i += 1;
                    }
                    else
                    {
                        i += 1;
                    }
                }
                QEvent = "Play a video";
                break;

            case "Show Email List":
                lstCommands.SelectionMode = SelectionMode.One;
                lstCommands.Items.Clear();
                lstCommands.Visible = true;
                foreach (string line in MsgList)
                {
                    lstCommands.Items.Add(line);
                }
                QEvent = "Checkfornewemails";
                break;

            case "Show listbox":
                lstCommands.Visible = true;
                break;

            case "Hide listbox":
                lstCommands.Visible = false;
                break;

            //SHUTDOWN RESTART LOG OFF
            case "Shutdown":
                if (ShutdownTimer.Enabled == false)
                {
                    QEvent = "shutdown";
                    JARVIS.SpeakAsync("I will shutdown shortly");
                    lblTimer.Visible      = true;
                    ShutdownTimer.Enabled = true;
                }
                break;

            case "Log off":
                if (ShutdownTimer.Enabled == false)
                {
                    QEvent = "logoff";
                    JARVIS.SpeakAsync("Logging off");
                    lblTimer.Visible      = true;
                    ShutdownTimer.Enabled = true;
                }
                break;

            case "Restart":
                if (ShutdownTimer.Enabled == false)
                {
                    QEvent = "restart";
                    JARVIS.SpeakAsync("I will be back shortly");
                    lblTimer.Visible      = true;
                    ShutdownTimer.Enabled = true;
                }
                break;

            case "Abort":
                if (ShutdownTimer.Enabled == true)
                {
                    timer                 = 11;
                    lblTimer.Text         = timer.ToString();
                    ShutdownTimer.Enabled = false;
                    lblTimer.Visible      = false;
                }
                break;

            //OTHER
            case "add custom commands":
            case "new command":
            case "add a command":
                Customize customwindow = new Customize();
                customwindow.Show();
                break;

            case "reload them":
            case "update commands":
            case "refresh commands":
            case "lets try that":
            case "ok i'm done":
                JARVIS.SpeakAsync("This may take a few seconds");
                _recognizer.UnloadGrammar(shellcommandgrammar);
                _recognizer.UnloadGrammar(webcommandgrammar);
                _recognizer.UnloadGrammar(socialcommandgrammar);
                ArrayShellCommands  = File.ReadAllLines(scpath);
                ArrayShellResponse  = File.ReadAllLines(srpath);
                ArrayShellLocation  = File.ReadAllLines(slpath);
                ArrayWebCommands    = File.ReadAllLines(webcpath);
                ArrayWebResponse    = File.ReadAllLines(webrpath);
                ArrayWebURL         = File.ReadAllLines(weblpath);
                ArraySocialCommands = File.ReadAllLines(socpath);
                ArraySocialResponse = File.ReadAllLines(sorpath);
                try
                { shellcommandgrammar = new Grammar(new GrammarBuilder(new Choices(ArrayShellCommands))); _recognizer.LoadGrammar(shellcommandgrammar); }
                catch
                { JARVIS.SpeakAsync("I've detected an in valid entry in your shell commands, possibly a blank line. Shell commands will cease to work until it is fixed."); }
                try
                { webcommandgrammar = new Grammar(new GrammarBuilder(new Choices(ArrayWebCommands))); _recognizer.LoadGrammar(webcommandgrammar); }
                catch
                { JARVIS.SpeakAsync("I've detected an in valid entry in your web commands, possibly a blank line. Web commands will cease to work until it is fixed."); }
                try
                { socialcommandgrammar = new Grammar(new GrammarBuilder(new Choices(ArraySocialCommands))); _recognizer.LoadGrammar(socialcommandgrammar); }
                catch
                { JARVIS.SpeakAsync("I've detected an in valid entry in your social commands, possibly a blank line. Social commands will cease to work until it is fixed."); }
                JARVIS.SpeakAsync("All commands updated");
                break;

            case "Reload libraries":
            case "update libraries":
            case "Refresh libraries":
                JARVIS.SpeakAsync("Loading libraries");
                try { _recognizer.UnloadGrammar(Allfiles); }
                catch { JARVIS.SpeakAsync("Previous grammar was invalid"); }
                QEvent = "ReadDirectories";
                ReadDirectories();
                break;

            case "Change the video directory":
                JARVIS.SpeakAsync("Please choose a directory to load your video files");
                VideoFBD.SelectedPath = Settings.Default.VideoFolder;
                VideoFBD.Description  = "Please select your video directory";
                DialogResult videoresult = VideoFBD.ShowDialog();
                if (videoresult == DialogResult.OK)
                {
                    Settings.Default.VideoFolder = VideoFBD.SelectedPath; Settings.Default.Save();
                    QEvent = "ReadDirectories";
                    ReadDirectories();
                }
                break;

            case "Change the music directory":
                JARVIS.SpeakAsync("Please choose a directory to load your music files");
                MusicFBD.SelectedPath = Settings.Default.MusicFolder;
                MusicFBD.Description  = "Please select your music directory";
                DialogResult musicresult = MusicFBD.ShowDialog();
                if (musicresult == DialogResult.OK)
                {
                    Settings.Default.MusicFolder = MusicFBD.SelectedPath; Settings.Default.Save();
                    QEvent = "ReadDirectories";
                    ReadDirectories();
                }
                break;

            case "Stop listening":
                JARVIS.SpeakAsync("I will await further commands");
                _recognizer.RecognizeAsyncCancel();
                startlistening.RecognizeAsync(RecognizeMode.Multiple);
                changelisten = true;
                break;

            //GMAIL NOTIFICATION
            case "Check for new emails":
                QEvent = "Checkfornewemails";
                JARVIS.SpeakAsyncCancelAll();
                EmailNum = 0;
                CheckForEmails();
                break;

            case "Open the email":
                try
                {
                    JARVIS.SpeakAsyncCancelAll();
                    JARVIS.SpeakAsync("Very well");
                    System.Diagnostics.Process.Start(MsgLink[EmailNum]);
                }
                catch { JARVIS.SpeakAsync("There are no emails to read"); }
                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;

            case "Clear email list":
                JARVIS.SpeakAsyncCancelAll();
                MsgList.Clear(); MsgLink.Clear(); lstCommands.Items.Clear(); EmailNum = 0; JARVIS.SpeakAsync("Email list has been cleared");
                break;
            }
        }
Exemple #3
0
 void Default_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
 int ranNum;
 string speech = e.Result.Text;
 switch (speech)
 {
 #region Greetings 
case "Hello":
 case "Hello Jarvis":
 timenow = DateTime.Now;
 if (timenow.Hour >= 5 && timenow.Hour < 12)
 {
 Jarvis.SpeakAsync("Goodmorning " + Settings.Default.User);
 }
 if (timenow.Hour >= 12 && timenow.Hour < 18)
 { Jarvis.SpeakAsync("Good afternoon " + Settings.Default.User);
 } if (timenow.Hour >= 18 && timenow.Hour < 24)
 { Jarvis.SpeakAsync("Good evening " + Settings.Default.User);
 } if (timenow.Hour < 5) 
{ Jarvis.SpeakAsync("Hello " + Settings.Default.User + ", it's getting late");
 }
 break;
 case "Goodbye": 
case "Goodbye Jarvis":
 case "Close Jarvis":
 Jarvis.Speak("Farewell"); 
Close(); 
break; 
case "Jarvis":
 ranNum = rnd.Next(1, 5);
 if (ranNum == 1) { QEvent = ""; Jarvis.SpeakAsync("Yes sir");
 } else if (ranNum == 2) { QEvent = ""; Jarvis.SpeakAsync("Yes?");
 } else if (ranNum == 3) { QEvent = ""; Jarvis.SpeakAsync("How may I help?");
 } 
else if (ranNum == 4) { QEvent = ""; Jarvis.SpeakAsync("How may I be of assistance?"); 
}
 break;
 case "What's my name?":
 Jarvis.SpeakAsync(Settings.Default.User);
 break;
 case "Stop talking": 
Jarvis.SpeakAsyncCancelAll();
 ranNum = rnd.Next(1, 5);
 if (ranNum == 5)
 { Jarvis.Speak("fine"); 
}
 break;
 #endregion
 
#region Condition of the Day
 case "What time is it":
 timenow = DateTime.Now;
 string time = timenow.GetDateTimeFormats('t')[0];
 Jarvis.SpeakAsync(time);
 break;
 
case "What day is it":
 Jarvis.SpeakAsync(DateTime.Today.ToString("dddd"));
 break;

 case "Whats the date":
 case "Whats todays date":
 Jarvis.SpeakAsync(DateTime.Today.ToString("dd-MM-yyyy"));
 break;

 case "Hows the weather":
 case "Whats the weather like":
 case "Whats it like outside":
 RSSReader.GetWeather();
 if (QEvent == "connected") 
{
 Jarvis.SpeakAsync("The weather in " + Town + " is " + Condition + " at " + Temperature + "
 degrees. There is a humidity of " + Humidity + " and a windspeed of " + WinSpeed + " miles per
 hour"); }
 else if (QEvent == "failed")
 {
 Jarvis.SpeakAsync("I seem to be having a bit of trouble connecting to the server. Just look
 out the window"); }
 break;
 case "What will tomorrow be like":
 case "Whats tomorrows forecast":
 case "Whats tomorrow like":
 RSSReader.GetWeather();
 if (QEvent == "connected")
 {
 Jarvis.SpeakAsync("Tomorrows forecast is " + TFCond + " with a high of " + TFHigh + "
 and a low of " + TFLow); }
 else if (QEvent == "failed") 
{
 Jarvis.SpeakAsync("I could not access the server, are you sure you have the right W O E I
 D?"); }
 break;
 
case "Whats the temperature":
 case "Whats the temperature outside":
 RSSReader.GetWeather();
 if (QEvent == "connected")
 {
 Jarvis.SpeakAsync(Temperature + " degrees"); }
 else if (QEvent == "failed")
 {
 Jarvis.SpeakAsync("I could not connect to the weather service"); }
 break;
 #endregion

 #region Application Commands
 case "Switch Window": SendKeys.SendWait("%{TAB " + count + "}");
 count += 1;
 break;
 
case "Close window":
 SendKeys.SendWait("%{F4}");
 break;

 case "Out of the way":
 if (WindowState == FormWindowState.Normal)
 {
 WindowState = FormWindowState.Minimized; Jarvis.SpeakAsync("My apologies");
 }
 break;

 case "Come back":
 if (WindowState == FormWindowState.Minimized)
 {
 Jarvis.SpeakAsync("Alright");
 WindowState = FormWindowState.Normal;
 }
 break;
 
case "Are Lights on?":
 JARVIS_SpeakCompleted.SpeakAsync("Let Me Check");
 break;
 
case "Show default commands":
 string[] defaultcommands = (File.ReadAllLines(@"Default Commands.txt"));
 Jarvis.SpeakAsync("Very well");
 lstCommands.Items.Clear();
 lstCommands.SelectionMode = SelectionMode.None;
 lstCommands.Visible = true;
 foreach (string command in defaultcommands)
 {
 lstCommands.Items.Add(command);
 } break;

 case "Show shell commands":
 Jarvis.SpeakAsync("Here we are");
 lstCommands.Items.Clear();
 lstCommands.SelectionMode = SelectionMode.None;
 lstCommands.Visible = true;
 foreach (string command in ArrayShellCommands) 
{
 lstCommands.Items.Add(command); 
}
 break;
 case "Show social commands":
 Jarvis.SpeakAsync("Alright");
 lstCommands.Items.Clear();
 lstCommands.SelectionMode = SelectionMode.None; 
lstCommands.Visible = true; 
foreach (string command in ArraySocialCommands)
 {
 lstCommands.Items.Add(command); 
}
 break;

 case "Show web commands":
 Jarvis.SpeakAsync("Ok");
 lstCommands.Items.Clear();
 lstCommands.SelectionMode = SelectionMode.None;
 lstCommands.Visible = true;
 foreach (string command in ArrayWebCommands)
 {
 lstCommands.Items.Add(command); }
 break;

 case "Show Music Library":
 lstCommands.SelectionMode = SelectionMode.One;
 lstCommands.Items.Clear();
 lstCommands.Visible = true;
 Jarvis.SpeakAsync("OK");
 i = 0; 
foreach (string file in MyMusicPaths) 
{ lstCommands.Items.Add(MyMusicNames[i]);
 i += 1; }
 QEvent = "Play music file";
 break;

 case "Show Video Library":
 lstCommands.SelectionMode = SelectionMode.One;
 lstCommands.Items.Clear();
 lstCommands.Visible = true;
 i = 0;
 foreach (string file in MyVideoPaths)
 {
 if (file.Contains(".mp4") || file.Contains(".avi") || file.Contains(".mkv")) 
{ lstCommands.Items.Add(MyVideoNames[i]); i += 1; }
 else { i += 1; } }
 QEvent = "Play video file";
 break;

 case "Show Email List":
 lstCommands.SelectionMode = SelectionMode.One;
 lstCommands.Items.Clear();
 lstCommands.Visible = true;
 foreach (string line in MsgList)
 { lstCommands.Items.Add(line); }
 QEvent = "Checkfornewemails";
 break; 
 case "Show listbox":
 lstCommands.Visible = true;
 break;

 case "Hide listbox":
 lstCommands.Visible = false;
 break; 
#endregion

 #region Shutdown / Restart / Logoff
 case "Shutdown": 
 if (ShutdownTimer.Enabled == false)
 { QEvent = "shutdown";
 Jarvis.SpeakAsync("Are you sure you want to " + QEvent + "?"); 
} break;
 case "Log off":
 if (ShutdownTimer.Enabled == false)
 { QEvent = "logoff";
 Jarvis.SpeakAsync("Are you sure you want to " + QEvent + "?"); }
 break;

 case "Restart":
 if (ShutdownTimer.Enabled == false)
 { QEvent = "restart";
 Jarvis.SpeakAsync("Are you sure you want to " + QEvent + "?"); }
 break;
 case "Abort": 
if (ShutdownTimer.Enabled == true)
 { timer = 11;
 lblTimer.Text = timer.ToString(); 
ShutdownTimer.Enabled = false;
 lblTimer.Visible = false; }
 break;
 #endregion

 #region Media Control Commands 
case "Play":
 axWindowsMediaPlayer1.Ctlcontrols.play();
 axWindowsMediaPlayer1.Visible = true;
 break;
 case "Play a random song": 
int Ran = rnd.Next(0, MyMusicPaths.Count());
 SelectedMusicFile = Ran;
 Jarvis.SpeakAsync("I hope you're in the mood for " + MyMusicNames[SelectedMusicFile]);
 axWindowsMediaPlayer1.URL = MyMusicPaths[SelectedMusicFile];
 break;
 case "You decide":
 if (QEvent == "Play music") {
 Ran = rnd.Next(0, MyMusicPaths.Count());
 SelectedMusicFile = Ran;
 Jarvis.SpeakAsync("How about " + MyMusicNames[SelectedMusicFile] + "?"); 
axWindowsMediaPlayer1.URL = MyMusicPaths[SelectedMusicFile]; }
 break;
 case "Pause":
 tmrMusic.Stop();
 axWindowsMediaPlayer1.Ctlcontrols.pause();
 break;
 case "Turn Shuffle On":
 Settings.Default.Shuffle = true;
 Settings.Default.Save();
 Jarvis.SpeakAsync("Shuffle enabled");
 break;

 case "Turn Shuffle Off":
 Settings.Default.Shuffle = false;
 Settings.Default.Save();
 Jarvis.SpeakAsync("Shuffle disabled");
 break;

 case "Turn Up": axWindowsMediaPlayer1.settings.volume += 10; 
lblVolume.Text = axWindowsMediaPlayer1.settings.volume.ToString() + "%";
 tbarVolume.Value = axWindowsMediaPlayer1.settings.volume;
 break;
 case "Turn Down":
 axWindowsMediaPlayer1.settings.volume -= 10; 
lblVolume.Text = axWindowsMediaPlayer1.settings.volume.ToString() + "%";
 tbarVolume.Value = axWindowsMediaPlayer1.settings.volume;
 break;
 case "Mute":
 axWindowsMediaPlayer1.settings.mute = true;
 lblVolume.Text = "mute"; 
break;
 case "Unmute":
 axWindowsMediaPlayer1.settings.mute = false;
 lblVolume.Text = axWindowsMediaPlayer1.settings.volume.ToString() + "%";
 break; 
case "Next Song":
 if (SelectedMusicFile != MyMusicPaths.Count() - 1)
 { if (Settings.Default.Shuffle == true)
 { Ran = rnd.Next(0, MyMusicPaths.Count());
 SelectedMusicFile = Ran; 
}
 else if (Settings.Default.Shuffle == false) 
{ SelectedMusicFile += 1; 
}
 axWindowsMediaPlayer1.URL = MyMusicPaths[SelectedMusicFile]; }
 break;
 case "Previous Song": 
if (SelectedMusicFile != 0)
 { SelectedMusicFile -= 1;
 axWindowsMediaPlayer1.URL = MyMusicPaths[SelectedMusicFile]; 
}
 break;
 case "Fast Forward":
 axWindowsMediaPlayer1.Ctlcontrols.fastForward();
 break;
 case "Stop Music":
 tmrMusic.Stop();
 axWindowsMediaPlayer1.URL = String.Empty;
 axWindowsMediaPlayer1.Ctlcontrols.stop();
 lblMusicTime.Visible = false;
 lblVolume.Visible = false;
 axWindowsMediaPlayer1.Visible = false;
 tbarVolume.Visible = false;
 tbarMusicTime.Visible = false;
 axWindowsMediaPlayer1.fullScreen = false;
 break;
 case "Fullscreen":
 try {
 axWindowsMediaPlayer1.fullScreen = true;
 }
 catch { } 
break;
 case "Exit Fullscreen":
 axWindowsMediaPlayer1.fullScreen = false;
 break; 
case "What song is playing":
 string filesourceURL = axWindowsMediaPlayer1.currentMedia.sourceURL;
 if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsPlaying) 
{
 Jarvis.SpeakAsync(MyMusicNames[SelectedMusicFile]); }
 else 
{ Jarvis.SpeakAsync("No song is currently being played"); } 
break;
 #endregion
 
#region Other Commands
 case "I want to add custom commands":
 case "I want to add a custom command":
 case "I want to add a command":
 Customize customwindow = new Customize(); 
customwindow.ShowDialog();
 break;

 case "Update commands": 
Jarvis.SpeakAsync("This may take a few seconds");
 _recognizer.UnloadGrammar(shellcommandgrammar); 
_recognizer.UnloadGrammar(webcommandgrammar); 
_recognizer.UnloadGrammar(socialcommandgrammar);
 ArrayShellCommands = File.ReadAllLines(scpath);
 ArrayShellResponse = File.ReadAllLines(srpath);
 ArrayShellLocation = File.ReadAllLines(slpath);
 ArrayWebCommands = File.ReadAllLines(webcpath);
 ArrayWebResponse = File.ReadAllLines(webrpath);
 ArrayWebURL = File.ReadAllLines(weblpath);
 ArraySocialCommands = File.ReadAllLines(socpath);
 ArraySocialResponse = File.ReadAllLines(sorpath);
 try 
{
 shellcommandgrammar = new Grammar(new GrammarBuilder(new
 Choices(ArrayShellCommands))); _recognizer.LoadGrammar(shellcommandgrammar); }
 catch
 {
 Jarvis.SpeakAsync("I've detected an in valid entry in your shell commands, possibly a
 blank line. Shell commands will cease to work until it is fixed."); }
 try
 {
 webcommandgrammar = new Grammar(new GrammarBuilder(new 
Choices(ArrayWebCommands))); _recognizer.LoadGrammar(webcommandgrammar); }
 catch 
{
 Jarvis.SpeakAsync("I've detected an in valid entry in your web commands, possibly a
 blank line. Web commands will cease to work until it is fixed."); }
 try 
{ 
socialcommandgrammar = new Grammar(new GrammarBuilder(new 
Choices(ArraySocialCommands))); 
_recognizer.LoadGrammar(socialcommandgrammar); }
 catch
 {
 Jarvis.SpeakAsync("I've detected an in valid entry in your social commands, possibly a
 blank line. Social commands will cease to work until it is fixed."); } 
Jarvis.SpeakAsync("All commands updated");
 break;

 case "Refresh libraries":
 Jarvis.SpeakAsync("Loading libraries");
 try {
 _recognizer.UnloadGrammar(MusicGrammar);
 _recognizer.UnloadGrammar(VideoGrammar);
 }
 catch { Jarvis.SpeakAsync("Previous grammar was invalid"); }
 File.Delete(@"C:\Users\" + Environment.UserName + "\\Documents\\Jarvis Custom
 Commands\\Filenames.txt");
 QEvent = "ReadDirectories"; 
ReadDirectories();
 break; 
case "Change video directory":
 Jarvis.SpeakAsync("Please choose a directory to load your video files"); 
VideoFBD.SelectedPath = Settings.Default.VideoFolder;
 VideoFBD.Description = "Please select your video directory";
 DialogResult videoresult = VideoFBD.ShowDialog();
 if (videoresult == DialogResult.OK)
 {
 Settings.Default.VideoFolder = VideoFBD.SelectedPath; Settings.Default.Save();
 QEvent = "ReadDirectories";
 ReadDirectories(); }
 break;

 case "Change music directory":
 Jarvis.SpeakAsync("Please choose a directory to load your music files");
 MusicFBD.SelectedPath = Settings.Default.MusicFolder;
 MusicFBD.Description = "Please select your music directory";
 DialogResult musicresult = MusicFBD.ShowDialog();
 if (musicresult == DialogResult.OK)
 {
 Settings.Default.MusicFolder = MusicFBD.SelectedPath; Settings.Default.Save();
 QEvent = "ReadDirectories";
 ReadDirectories(); }
 break;
 case "Stop listening":
 Jarvis.SpeakAsync("I will await further commands"); 
_recognizer.RecognizeAsyncCancel();
 startlistening.RecognizeAsync(RecognizeMode.Multiple); 
break; 
#endregion

 #region Gmail Notification
 case "Check for new emails":
 QEvent = "Checkfornewemails";
 Jarvis.SpeakAsyncCancelAll();
 EmailNum = 0;
 RSSReader.CheckForEmails();
 break;
 case "Open the email":
 try { 
Jarvis.SpeakAsyncCancelAll();
 Jarvis.SpeakAsync("Very well");
 System.Diagnostics.Process.Start(MsgLink[EmailNum]); }
 catch { Jarvis.SpeakAsync("There are no emails to read"); } 
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; 
case "Clear email list": Jarvis.SpeakAsyncCancelAll();
 MsgList.Clear(); MsgLink.Clear(); lstCommands.Items.Clear(); EmailNum = 0;
 Jarvis.SpeakAsync("Email list has been cleared");
 break;
 #endregion

 #region Updating
 case "Change Language":
 AskForACountry();
 break;
 case "Check for new updates":
 Jarvis.SpeakAsync("Let me see if Michael has posted anything");
 RSSReader.CheckBloggerForUpdates(); 
break; 
case "Yes": 
if (QEvent == "UpdateYesNo")
 { Jarvis.SpeakAsync("Thank you. I shall initialize the download immediately. Simply 
uninstall me and then install the new me. Would you like me to open the blog for specific information
 on the update?");
 System.Diagnostics.Process.Start(Settings.Default.RecentUpdate);
 QEvent = "OpenBlog"; 
}
 else if (QEvent == "OpenBlog")
 {
 Jarvis.SpeakAsync("Very well, consider it done");
 System.Diagnostics.Process.Start("http://michaelcjarvis.blogspot.com/2013/09/michael-
cs-customizable-jarvis.html");
 QEvent = String.Empty; }
 else if (QEvent == "shutdown" || QEvent == "logoff" || QEvent == "restart")
 {
 Jarvis.SpeakAsync("I will begin the countdown to " + QEvent);
 ShutdownTimer.Enabled = true;
 lblTimer.Visible = true; }
 break;
 case "No": 
if (QEvent == "UpdateYesNo")
 { 
Jarvis.SpeakAsync("Very well. I guess I don't need any improvement");
 Settings.Default.RecentUpdate = String.Empty; Settings.Default.Save();
 QEvent = String.Empty; }
 else if (QEvent == "OpenBlog")
 {
 Jarvis.SpeakAsync("Learn by doing I suppose"); 
QEvent = String.Empty; }
 else if (QEvent == "shutdown" || QEvent == "logoff" || QEvent == "restart")
 {
 Jarvis.SpeakAsync("My mistake");
 QEvent = String.Empty; }
 break;
 #endregion }
 }
 void startlistening_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
 string speech = e.Result.Text;
 switch (speech)
 {
 case "Jarvis": 
startlistening.RecognizeAsyncCancel();
 Jarvis.SpeakAsync("Yes?");
 _recognizer.RecognizeAsync(RecognizeMode.Multiple); 
break;
 }
 }
 }