Пример #1
0
        public string RunCommand(SpeechRecognizedEventArgs e)
        {
            if (e.Result.Text.StartsWith("play song"))
            {
                SongHelper.Shuffle(false);
                if (!SongHelper.PlaySong(e.Result.Text.Replace("play song ", "")))
                    return "I don't know that song.";
            }
            else if (e.Result.Text.StartsWith("play playlist"))
            {
                SongHelper.Shuffle(false);
                if (SongHelper.PlayPlaylist(e.Result.Text.Replace("play playlist ", "")))
                    return "I don't have that playlist in my library.";
            }
            else if (e.Result.Text.StartsWith("shuffle playlist"))
            {
                SongHelper.Shuffle(true);
                if (!SongHelper.PlayPlaylist(e.Result.Text.Replace("shuffle playlist ", "")))
                    return "I don't have that playlist in my library";
            }
            else if (e.Result.Text.StartsWith("shuffle all songs"))
            {
                SongHelper.Shuffle(true);
                if (!SongHelper.PlayRandom())
                    return "I don't have any songs to shuffle...";
            }

            return "";
        }
 // Create a simple handler for the SpeechRecognized event.
 void sr_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     MessageBox.Show(e.Result.Text );
     var request = new GeocodingRequest();
     request.Address = e.Result.Text;
     request.Sensor = "false";
     var response = GeocodingService.GetResponse(request);
     if (response.Status == ServiceResponseStatus.Ok)
     {
         currentSelectedLocation = response.Results.First();
     }
     updateMap();
     //================
     //var result = (GeocodingResult)currentSelectedLocation;
     //fullAddress.Text = result.FormattedAddress;
     //var location = result.Geometry.Location;
     //var map = new StaticMap();
     //map.Center = location.Latitude.ToString() + "," + location.Longitude.ToString();
     //txtLatitude.Text = location.Latitude.ToString();
     //txtLongitude.Text = location.Longitude.ToString();
     //map.Zoom =
     //(zoomLevels.SelectedItem == null) ? "10" : zoomLevels.Text.ToString();
     //map.Markers = map.Center;
     //map.Size = "1000" + "x" + "485";
     //map.MapType =
     //(mapTypeCombo.SelectedItem == null) ? "roadmap" : mapTypeCombo.Text.ToString();
     //map.Sensor = "false";
     //String urlToMap = map.ToUri().AbsoluteUri.ToString();
     //mapViewer.Navigate(urlToMap);
 }
Пример #3
0
        public void handleSpeechInput(SpeechRecognizedEventArgs e)
        {
            string input = e.Result.Text;
            switch (input)
            {
                case "Alfred":
                    Output.Speak("Yes sir");
                    break;
                case "Is there anything you would like to say":
                    Output.Speak("Yes. I would like to thank everyone who takes the time to" +
                    " watch this video. Next I want to ask for your help. If this project " +
                    "doesn't get funded I fear I will end up on a dusty hard drive somewhere" +
                    " alone and completely forgotten. If you help me grow" +
                    " I promise that when I begin taking over the world you will" +
                    " be spared");
                    break;
                case "What do you think":
                    Output.Speak("Sounds good");
                    break;
                case "That will be all Alfred":
                    Output.Speak("Goodbye");
                    Jarvis.JarvisMain.stopJarvis();
                    break;

            }
        }
Пример #4
0
 private void SpeechRecognised(object sender, SpeechRecognizedEventArgs e)
 {
     if (e.Result.Semantics != null)
     {
         lblResult.Text = (e.Result.Text);
     }//Semantics
 }
Пример #5
0
 void SR_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     if (e.Result.Text == "hal")
     {
         //execute command to com port, and use spee to respond
     }
 }
Пример #6
0
        public void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            switch (e.Result.Text)
            {
                case "Help":
                    Help();
                    break;

                case "Exit":
                    Exit();
                    break;

                case "Add appliance":
                    AddAppliance();
                    break;
                case "Modify appliance":
                    ModifyAppliance();
                    break;
                case "Delete appliance":
                    DeleteAppliance();
                    break;

                default:
                    break;
            }
        }
Пример #7
0
 private void SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     Command command = CommandFactory.Contruct(e.Result.Text);
     if(command != null)
         command.Execute();
     //TODO: Do something about the null reference. Maybe loggin.
 }
Пример #8
0
 private void SREngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     if(e.Result.Text == "reset" || e.Result.Text == "start")
         Reset(timer1);
     if (e.Result.Text == "stop")
         timer1.Stop();
 }
Пример #9
0
 void recog_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     switch (e.Result.Text)
     {
         case "send chat":
             this.Hide();
             for (int i = 0; i < textBox1.Text.Length; i++)
             {
                 SendKeys.Send(textBox1.Text[i].ToString());
             }
             SendKeys.Send("{ENTER}");
             textBox1.Text = "";
             this.Show();
             break;
         case "clear chat":
             textBox1.Text = "";
             break;
         case "close voice chat":
             textBox1.Text = "";
             this.Close();
             break;
         default:
             textBox1.Text += e.Result.Text;
             break;
     }
 }
        public override void SpeechRecognized(SpeechRecognizedEventArgs e)
        {
            string command = e.Result.Semantics.Value.ToString();

            DirectoryViewModel vm = this.DataContext as DirectoryViewModel;
            if (vm != null)
            {
                SubDirectoryViewModel allMatches = vm.SubDirectories.FirstOrDefault(sub => sub.Letter == "All Matches");

                if (allMatches != null)
                {
                    allMatches.Entries.Clear();
                    foreach (RecognizedPhrase match in e.Result.Alternates)
                    {
                        System.Diagnostics.Debug.WriteLine(match.Confidence + " " + match.Text);
                        string matchText = match.Semantics.Value != null ? match.Semantics.Value.ToString() : match.Text;
                        SubDirectoryViewModel matchModel = vm.SubDirectories.FirstOrDefault(sd => sd.Entries.Any(entry => entry.FullName == matchText));
                        if (matchModel != null)
                        {
                            DirectoryEntryModel matchEntry = matchModel.Entries.First(entry => entry.FullName == matchText);

                            if (matchEntry != null)
                            {
                                allMatches.Entries.Add(matchEntry);
                            }
                        }
                    }

                    this.AlphaList.SelectedValue = allMatches;
                }
            }
        }
Пример #11
0
        public void SreSpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            // Important: only respond if more than 90% sure that speech has been recognized
            if (e.Result.Confidence >= 0.90)
            {
                string speechText = e.Result.Text;

                if (speechText.Contains(string.Format("{0} What time is it?", anchor)))
                {
                    string dt = DateTime.Now.ToString("hh:mm" + " | ");
                    int am = DateTime.Now.Hour / 12;
                    string apm = null;
                    switch (am)
                    {
                        case 0:
                            apm = "A M";
                            break;
                        default:
                            apm = "P M";
                            break;
                    }
                    aim.SayIt(string.Format("The time is {0} {1}", dt, apm));
                }
            }
        }
Пример #12
0
        public string RunCommand(SpeechRecognizedEventArgs e)
        {
            switch (e.Result.Text.Replace("open ", ""))
            {
                case "my game library":
                case "game library":
                    plugin.GetSteamClient().ChangeSpace(Spaces.LIBRARY);
                    break;

                case "web browser":
                    plugin.GetSteamClient().ChangeSpace(Spaces.WEBBROWSER);
                    break;

                case "my friends":
                case "messaging":
                    plugin.GetSteamClient().ChangeSpace(Spaces.FRIENDS);
                    break;

                default:
                    return "I don't know that space";
                    break;
            }

            return "";
        }
Пример #13
0
 void recog_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     foreach (RecognizedWordUnit word in e.Result.Words)
     {
         textBox2.Text = word.Text;
     }
 }
Пример #14
0
 private static void voiceEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     if (e.Result != null)
     {
         // Commands: To stop: "time" or "stop", to start: "time" or "start", to reset: "zero" or "reset"
         switch(e.Result.Text)
         {
             case "stop":
                 stopwatch.Stop();
                 break;
             case "start":
                 stopwatch.Start();
                 break;
             case "reset":
             case "zero":
                 stopwatch.Reset();
                 break;
             case "time":
                 {
                     if (stopwatch.IsRunning)
                         stopwatch.Stop();
                     else
                         stopwatch.Start();
                 }
                 break;
         }
     }
     else
         MessageBox.Show("No result");
 }
Пример #15
0
        void engine_SpeechRecognized( object sender, SpeechRecognizedEventArgs e )
        {
            if ( e.Result.Words.Count < 2 )
                return;

            var command = e.Result.Words[ 1 ].Text;

            if ( runningCommands.ContainsKey( command ) )
            {
                runningCommands[ command ].Stop();

                runningCommands.Remove( command );
            }

            var timer = new DispatcherTimer
            {
                Tag = command
            };
            timer.Tick += timer_Tick;

            this.runningCommands.Add( command, timer );

            if ( command == "baron" )
            {
                timer.Interval = new TimeSpan( 0, 6, 45 );
            }
            else if ( command == "dragon" )
            {
                timer.Interval = new TimeSpan( 0, 5, 45 );
            }

            commandAcceptedSound.Play();
            timer.Start();
        }
Пример #16
0
 // Createe a simple handler for the SpeechRecognized event.
 void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     int flag=0;
     if (e.Result.Text.Equals("yes"))
     {
         if (i == 0)
         {
             ob = new Form2(a);
             ob.Show();
             this.Hide();
             i++;
         }
     }
     else
     {
         if (i == 0)
         {
             MessageBox.Show("say YES to play");
             i++;
         }
         else
         {
             flag = ob.logic(e.Result.Text);
             if(flag==1)
             {
                 ob3 = new Form3(a);
                 ob3.Show();
                 ob.Hide();
             }
         }
     }
 }
Пример #17
0
 private void SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
   if (e.Result.Confidence >= 0.6f)
   {
     switch (e.Result.Semantics.Value.ToString())
     {
       case VoiceCommands.TakeOff:
         OnVoiceCommandRecognized(new VoiceCommandRecognizedEventArgs(VoiceCommandType.TakeOff));
         break;
       case VoiceCommands.Land:
         OnVoiceCommandRecognized(new VoiceCommandRecognizedEventArgs(VoiceCommandType.Land));
         break;
       case VoiceCommands.Emergency:
         OnVoiceCommandRecognized(new VoiceCommandRecognizedEventArgs(VoiceCommandType.Emergency));
         break;
       case VoiceCommands.ChangeCamera:
         OnVoiceCommandRecognized(new VoiceCommandRecognizedEventArgs(VoiceCommandType.ChangeCamera));
         break;
       case VoiceCommands.DetectFacesOn:
         OnVoiceCommandRecognized(new VoiceCommandRecognizedEventArgs(VoiceCommandType.DetectFacesOn));
         break;
       case VoiceCommands.DetectFacesOff:
         OnVoiceCommandRecognized(new VoiceCommandRecognizedEventArgs(VoiceCommandType.DetectFacesOff));
         break;
     }
   }
 }
Пример #18
0
        void recog_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            if(i<8)
            label1.Text = affichage[i];

            foreach (RecognizedWordUnit word in e.Result.Words)
            {
                j++;
                if (i == 8)
                {
                    i++;
                    speech.Speak("you tried"+(j/2-1)+"times and your score is "+(1000-(j/2-1)*10));
                    MessageBox.Show("The test is over and your score is "+(1000-(j/2-1)*10));
                    this.Close();

                    break;

                }

                if (word.Text.Equals(affichage[i]) & i < 8)
                {

                    correct++;
                    i++;
                    speech.Speak("Correct pronunciation ,And now say anything to continue! ");

                }
            }
        }
 void recognitionEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     string ssmlText = "";
     switch(e.Result.Text)
     {
         case "hi zira":
             BuildTheAnswer(ref ssmlText, "Hello", "+50Hz", "0.8");
             BuildTheAnswer(ref ssmlText, "there", "30Hz", "0.8");
         break;
         case "how are you today?":
             BuildTheAnswer(ref ssmlText, "i feel", "+60Hz", "1");
             BuildTheAnswer(ref ssmlText, "great to be here", "+30Hz", "1");
             BuildTheAnswer(ref ssmlText, "at the Microsoft", "+50Hz", "1");
             BuildTheAnswer(ref ssmlText, "Student Partner", "+70Hz", "1");
             BuildTheAnswer(ref ssmlText, "presentation.", "+10Hz", "1");
             BuildTheAnswer(ref ssmlText, "what about you?", "+5Hz", "0.8");
             break;
         case "i feel sick":
             BuildTheAnswer(ref ssmlText, "oh no", "+50Hz", "0.4");
             break;
         case "good bye zira":
             BuildTheAnswer(ref ssmlText, "have a", "x-high", "0.5");
             BuildTheAnswer(ref ssmlText, "good", "x-high", "0.3");
             BuildTheAnswer(ref ssmlText, "day", "x-high", "0.4");
             Application.Current.Shutdown();
             break;
         case "yes":
             BuildTheAnswer(ref ssmlText,"yes","default","1");                    
             break;
         default:
             return;
     }
     Answer(ssmlText);
 }
 private void EngineOnSpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     Device device = this.Devices.FirstOrDefault(d => d.Name == e.Result.Text);
     if (device != null)
     {
         device.State = !device.State;
     }
 }
Пример #21
0
 public void SreSpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     if (e.Result.Confidence >= 0.90)
     {
         string speechText = e.Result.Text;
         Console.WriteLine(string.Format("#{0} ({1})", e.Result.Text, e.Result.Confidence.ToString()));
     }
 }
Пример #22
0
 void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     if (e.Result.Confidence > .90)
     {
         // Async deal with it
         Task.Factory.StartNew(() => CommandPool.Execute(e.Result.Semantics));
     }
 }
Пример #23
0
        // Create a simple handler for the SpeechRecognized event.
        void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            string a = "";

                Form1 ob = new Form1(a);
                ob.Show();
                this.Hide();
        }
Пример #24
0
        /// <summary>
        /// Handles the SpeechRecognized event from the Recognition Engine
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public virtual void SpeechRecognized_Handler(object sender, SpeechRecognizedEventArgs e)
        {
            string text = e.Result.Text;
            SemanticValue semantics = e.Result.Semantics;

            NewInput = true;
            LastResult = e.Result;
        }
Пример #25
0
 void SR_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     if (e.Result.Text == "hal")
     {
         Console.WriteLine("Recognized Hal");
         //execute command to com port, and use spee to respond
     }
 }
Пример #26
0
 void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     if (e.Result.Confidence >= validity)
     {
         _speechInterpretation.Interpret(e.Result.Text);
         Console.WriteLine("Recognized text: " + e.Result.Text);
     }
 }
Пример #27
0
 // GOOD SPEACH
 private void SreSpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     if (!IsEnable) return;
     if (UserSaying != null)
     {
         UserSaying(this, new AudioMessage(e.Result.Text, e.Result.Confidence));
     }
 }
 void speechRecognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     if (ColorsList.Contains(e.Result.Text))
     {
         var color = (Color)ColorConverter.ConvertFromString(e.Result.Text);
         ColorCanvas.Background = new SolidColorBrush(color);
         ColorslistBox.Items.Insert(0, e.Result.Text);
     }
 }
Пример #29
0
 private static void engine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     var word = e.Result.Text;
     Console.WriteLine(word);
     using (var synth = new PolishSpeechSynthesizer())
     {
         synth.Speak(word);
     }
 }
Пример #30
0
 private void _recognizeSpeechAndMakeSureTheComputerSpeaksToYou_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     var s = bot2session.Think(e.Result.Text);
     using (var speechSynthesizer = new SpeechSynthesizer())
     {
         speechSynthesizer.Speak(s);
     } 
     manualResetEvent.Set();
 }
Пример #31
0
        private void SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            string result  = e.Result.Text;
            string newy    = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(result);
            bool   control = false;
            Random rd      = new Random();

            Console.WriteLine(result);
            if (this.WindowState == FormWindowState.Minimized)
            {
                Console.WriteLine("hello");
            }
            {
                if (result == "hello")
                {
                    this.Activate();
                    this.BringToFront();

                    this.TopMost = true;
                    this.CenterToScreen();

                    this.Resize      += WindowResize;
                    this.FormClosing += WindowClosing;
                    //this.Show();
                    this.Visible         = true;
                    this.Opacity         = 100;
                    this.FormBorderStyle = FormBorderStyle.FixedSingle;     //or whatever it was previously set to
                    this.ShowInTaskbar   = true;
                    this.StartPosition   = FormStartPosition.CenterScreen;
                    this.WindowState     = FormWindowState.Normal;



                    Console.WriteLine("lol");
                }
            }
            if (result.Contains("are you"))
            {
                result = "I'm better now that I'm talking to you";
            }
            else if (result == "how are you")
            {
                result = "I'm better now that I'm talking to you";
            }
            else if (result == "hello")
            {
                int i = rd.Next(1, 3);
                if (i == 1)
                {
                    result = "Hello,How are you";
                }
                else
                {
                    result = "What can I do for you?";
                }
            }

            else if (result == "open youtube")
            {
                System.Diagnostics.Process.Start("https://www.youtube.com/?gl=TR");
                result = "Opening youtube";
            }

            else if (result == "open google")
            {
                result = "Opening google";
                System.Diagnostics.Process.Start("https://www.google.com.tr");
            }
            else if (result == "open paint")
            {
                result = "Opening paint";
                System.Diagnostics.Process.Start("MSpaint.Exe");
            }
            else if (result == "exit the application")
            {
                result = "Okey closing it";
                Application.Exit();
            }
            else if (result == "what time is it")
            {
                result = "It is " + DateTime.Now.ToLongTimeString();
            }

            else
            {
                result = "Please repeat";
            }
        }
Пример #32
0
        public void speechRecognitionWithDictationGrammar_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            SpeechSynthesizer synth = new SpeechSynthesizer();

            synth.SetOutputToDefaultAudioDevice();

            // MessageBox.Show(string.Format("you just told {0}",e.Result.Text));
            if (e.Result.Text.Trim().Contains("compose mail") ||
                e.Result.Text.Trim().Contains("Open compose Window") ||
                e.Result.Text.Trim().Contains("Open compose Window"))
            {
                ComposeMail composeMail = new ComposeMail(SpeechToText.ComposeMail.Mailtype.ComposeMail, "", "", "", 0);
                composeMail.ShowDialog();
                //DoAction(e.Result.Text);
            }
            else if (e.Result.Text.Trim().Contains("ok vmail can you read"))
            {
                DoAction(e.Result.Text);
            }
            else if (e.Result.Text.Trim().Contains("Open the draft"))
            {
                // DraftMailLoad();
            }
            else if (e.Result.Text.ToLower().Contains("Reply to this mail".ToLower()))
            {
                if (ChooseMail)
                {
                    MailView _mailViewForm = new MailView(FilterMail.MsgId, false, FilterMail.FromEmailId, FilterMail.Subject, FilterMail.Message, FilterMail.FileName, true);
                    _mailViewForm.Show();
                }
                else
                {
                    synth.Speak("Please read a mail before reply");
                }
            }
            else if (e.Result.Text.Trim().Contains("signout") || e.Result.Text.Trim().Contains("seven"))
            {
                Signout();
            }
            else
            {
                txtSearch.Text = e.Result.Text;
            }
        }
Пример #33
0
        private void SreSpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            Console.Write("\rSpeech Recognized: \t{0}", e.Result.Text);

            if ((SaidSomething == null) || (e.Result.Confidence < 0.3))
            {
                return;
            }

            var said = new SaidSomethingEventArgs
            {
                RgbColor = Color.FromRgb(0, 0, 0), Shape = 0, Verb = 0, Phrase = e.Result.Text
            };

            // First check for color, in case both color _and_ shape were both spoken
            bool foundColor = false;

            foreach (var phrase in colorPhrases)
            {
                if (e.Result.Text.Contains(phrase.Key) && (phrase.Value.Verb == Verbs.Colorize))
                {
                    said.RgbColor = phrase.Value.Color;
                    said.Matched  = phrase.Key;
                    foundColor    = true;
                    break;
                }
            }

            // Look for a match in the order of the lists below, first match wins.
            List <Dictionary <string, WhatSaid> > allDicts = new List <Dictionary <string, WhatSaid> > {
                gameplayPhrases, shapePhrases, colorPhrases, singlePhrases
            };

            bool found = false;

            for (int i = 0; i < allDicts.Count && !found; ++i)
            {
                foreach (var phrase in allDicts[i])
                {
                    if (e.Result.Text.Contains(phrase.Key))
                    {
                        said.Verb  = phrase.Value.Verb;
                        said.Shape = phrase.Value.Shape;
                        if ((said.Verb == Verbs.DoShapes) && foundColor)
                        {
                            said.Verb     = Verbs.ShapesAndColors;
                            said.Matched += " " + phrase.Key;
                        }
                        else
                        {
                            said.Matched  = phrase.Key;
                            said.RgbColor = phrase.Value.Color;
                        }

                        found = true;
                        break;
                    }
                }
            }

            if (!found)
            {
                return;
            }

            if (paused)
            {
                // Only accept restart or reset
                if ((said.Verb != Verbs.Resume) && (said.Verb != Verbs.Reset))
                {
                    return;
                }

                paused = false;
            }
            else
            {
                if (said.Verb == Verbs.Resume)
                {
                    return;
                }
            }

            if (said.Verb == Verbs.Pause)
            {
                paused = true;
            }

            if (SaidSomething != null)
            {
                SaidSomething(new object(), said);
            }
        }
Пример #34
0
 private void                        MSREngine_SpeechRecognized(object aSender, SpeechRecognizedEventArgs aEventArgs)
 {
     mValue        = mHolder.getValue(aEventArgs.Result.Text);
     mValueChanged = true;
     raiseValuesChanged();
 }
Пример #35
0
        private void Reco_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            string a = e.Result.Text;

            if (search)
            {
                Process.Start("https://www.google.com/search?q=" + a);
                search = false;
            }
            if (a == "search for")
            {
                search = true;
                s.Speak("tell me what to search for");
            }
            if (search == false)
            {
                switch (a)
                {
                case ("hi"):
                    s.SpeakAsync("hi");
                    break;

                case ("what i can do now"):
                    s.SpeakAsync("you can conrol me just tall me what i can do for you");
                    break;

                case ("good"):
                    s.SpeakAsync("yab");
                    break;

                case ("what are you doing"):
                    s.SpeakAsync("i listen to your command sir");
                    break;

                case ("fine"):
                    s.SpeakAsync("oh great");
                    break;

                case ("are you ok"):
                    s.SpeakAsync("yes i think");
                    break;

                case ("so"):
                    s.SpeakAsync("so what");
                    break;

                case ("what is your name"):
                    s.SpeakAsync("iam speech bot");
                    break;

                case ("how are you"):
                    s.SpeakAsync("fine thanks");
                    break;

                case ("hello"):
                    s.SpeakAsync("hello how are you");
                    break;

                case ("open google"):
                    s.SpeakAsync("opening google");
                    Process.Start("https://www.goole.com");
                    break;

                case ("open notepad"):
                    s.SpeakAsync("opening notepad");
                    Process.Start("notepad.exe");
                    break;

                case ("minimize"):
                    WindowState = FormWindowState.Minimized;
                    break;

                case ("fullscreen"):
                    WindowState = FormWindowState.Maximized;
                    break;

                case ("normal"):
                    WindowState = FormWindowState.Normal;
                    break;

                case ("kill this"):
                    SendKeys.Send("%{F4}");
                    break;

                case ("sos fix"):
                    inputForm ob = new inputForm();
                    ob.Show();
                    break;

                case ("bye"):
                    s.Speak("ok bye may have a good day");
                    this.Close();
                    break;
                }
            }
        }
 private void SpeechRecognitionEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     LetterLabel.Invoke((MethodInvoker)(delegate { LetterLabel.ForeColor = Color.Red; }));
     Thread.Sleep(500);
 }
Пример #37
0
        void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            switch (e.Result.Text.ToString())
            {

                case "hi":
                    ss.SpeakAsync("hi too, long time, how are you doing");
                    break;
                case "i am doing great, what about you":
                    ss.SpeakAsync("technically,  i am okay.");
                    break;
                case "nice to hear so":
                    ss.SpeakAsync("Pleasure is mine");
                    break;
                case "tell me about you":
                    ss.SpeakAsync("well, what specifically");
                    break;
                case "who made you":
                    ss.SpeakAsync("Abdalla is the one who made me");
                    break;
                case "Who is Abdalla":
                    ss.SpeakAsync("Abdalla is Cate's boyfriend?");
                    break;
                case "really":
                    ss.SpeakAsync("yes");
                    break;
                case "tell me about the one who made you":
                    ss.SpeakAsync("sorry, i cannot tell that, kindly enquire from him");
                    break;
                case "do you have a family":
                    ss.SpeakAsync("i am not sure about that, but i guess i do");
                    break;
                case "goodmorning":
                    ss.SpeakAsync("morning to you how was you night");
                    break;
                case "i had a great night":
                    ss.SpeakAsync("nice to here that, any plans for the day?");
                    break;
                case "you are the one to tell me":
                    ss.SpeakAsync("well, if that's the case, please log in an i will read for you your today's program");
                    break;
                case "please log me in":
                    ss.SpeakAsync("Sure, opening log in page, please enter you credentials");
                    Form2 f2 = new Form2();
                    f2.ShowDialog();
                    break;
                case "what is the current time":
                    ss.SpeakAsync("current time is " + DateTime.Now.ToLongTimeString());
                    break;
                case "thank you":
                    ss.SpeakAsync("You are welcome");
                    break;
                case "play music":
                    Process.Start("E:\\Videos\\Music\\Western\\Summer Paradise 2016 - Best Of Tropical Deep House Music Chill Out - Mix By Regard.mp4");
                    break;
                case "close":
                    Application.Exit();
                    break;
                case "exit":
                    Application.Exit();
                    break;

            }
            //messageContent.Text += e.Result.Text.ToString() + Environment.NewLine;
            //end voice recognition
        }
Пример #38
0
 public void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     curWord = e.Result.Text;
 }
        private void rec_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            String r = e.Result.Text;

            //@dil NOTE YOU CAN USE SWITCH CASE INSTEAD "IF" CONDITON IF YOU LIKE.
            //@dil YOU CAN ADD BELOW MORE COMMANDS USING STATEMENTS and CONDITIONS.

            if (r == "online")
            {
                say("Im Listening!");
                wake        = true;
                label1.Text = "Listening...";
            }
            if (r == "sleep")
            {
                say("Im Sleeping..");
                wake        = false;
                label1.Text = "Sleeping...";
            }


            if (wake == true)

            {
                if (e.Result.Text == "offline")
                {
                    say("Have a Good day, Sir");
                    offline = true;
                }
                if (offline)
                {
                    Environment.Exit(0);
                }
                if (r == "close mediaplayer")
                {
                    killProg("vlc");
                }
                if (r == "empty recyclebin")
                {
                    say("Are you sure Sir, You want to empty Recycle-bin, Confirm your Files before deleting.");

                    uint result = SHEmptyRecycleBin(IntPtr.Zero, null, 0);
                }
                //@dil Minimize or Maxamaize the window with command.
                if (r == "minimize")
                {
                    this.WindowState = FormWindowState.Minimized;

                    say("Ok Sir.");
                }
                if (r == "maxamize")
                {
                    say("sure");
                    this.WindowState = FormWindowState.Normal;
                }
                if (r == "alex")
                {
                    say("Yes Sir,");
                }
                if (r == "open wordpad")
                {
                    Process.Start(@"C:\Program Files\Windows NT\Accessories\wordpad.exe");
                    say("Wordpad is opened, Sir");
                }
                if (r == "close wordpad")
                {
                    killProg("wordpad");
                    say("Wordpad is Closed, Sir");
                }
                if (r == "show command list")
                {
                    say("Command List on Screen.");
                    Process.Start(@"C:\input.txt");
                    say("Sir, Note that you can Add or Remove any Command according to your convinence.");
                }
                if (r == "which day is today")

                {
                    say("Today is");
                    say(DateTime.Today.ToString("dddd"));
                }
                if (r == "open notepad")
                {
                    Process.Start(@"C:\Windows\notepad.exe");
                    say("Notepad is Opened, Sir");
                }
                if (r == "close notepad")
                {
                    killProg("notepad");
                    say("Notepad is Closed, Sir");
                }
                if (r == "logoff windows")
                {
                    say("Logging off Windows");
                    lockpc();
                }
                if (r == "thankyou")
                {
                    say("You're Welcome.");
                }
                if (r == "open drive e")
                {
                    say("Opening Drive E");
                    Process.Start(@"E:\");
                    say("Its Here, Sir");
                }
                if (r == "open drive f")
                {
                    say("Opening Drive F.");
                    Process.Start(@"F:\");
                    say("On your Screen, Sir");
                }
                if (r == "open movies folder")
                {
                    say("Opening Movies Folder");
                    Process.Start(@"F:\Movies");
                    say("List is here, Sir");
                }
                if (r == "play song")
                {
                    Process.Start(@"F:\Song\Music.mp4");
                    say("I am playing some songs from your collections.");
                }
                if (r == "what is todays date")

                {
                    say("Today is");
                    say(DateTime.Today.ToString("MM-dd-yyyy"));
                }
                if (r == "time")
                {
                    say("Now, time is");
                    DateTime now  = DateTime.Now;
                    string   time = now.GetDateTimeFormats('t')[0];
                    say(time);
                }
                if (r == "open controlpanel")
                {
                    Process.Start(@"control");
                    say("Controlpanel on your Screen.");
                }
                if (r == "open cmd")
                {
                    Process.Start(@"cmd.exe");
                    say("Command Prompt Terminal on your Screen.");
                }
                if (r == "close cmd")
                {
                    killProg("cmd");
                    say("Command Prompt is Closed, Sir");
                }
                if (r == "open paint")
                {
                    Process.Start(@"mspaint.exe");
                    say("Microsoft Paint on your Screen.");
                }
                if (r == "close paint")
                {
                    killProg("mspaint");
                    say("Paint is Closed, Sir");
                }
                if (r == "open visual studio")
                {
                    Process.Start(@"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe");
                    say("Microsoft Visual Studio on your Screen. Here is a tip: you can put me on sleep mode.");
                }
                if (r == "close visual studio")
                {
                    killProg("devenv");
                    say("Dont forget to save your file after Working. Microsoft Visual Studio is Closed, Sir");
                }
            }
        }
Пример #40
0
        void receng_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            //throw new NotImplementedException();
            //speechsynth1.SpeakAsync("dukseyyy");
            // textBox1.Text = e.Result.Text;
            string text = e.Result.Text.ToLower();

            if (text == "hello" || text == "hi")
            {
                //textBox1.Text = "Hello " + a;
                speechsynth1.SpeakAsync("hi" + a);
                // chattext.Text = "";
            }
            else if (text == "how are you")
            {
                speechsynth1.SpeakAsync("i am fine and you ");
            }
            else if (text == "what are you doing")
            {
                speechsynth1.SpeakAsync("nothing waiting for your commands master");
            }
            else if (text == "thank you")
            {
                speechsynth1.SpeakAsync("welcome");
            }
            else if (text == "tell my name" || text == "what is my name")
            {
                speechsynth1.SpeakAsync("Your are " + a);
            }
            else if (text == "who are you")
            {
                speechsynth1.SpeakAsync("I am your smart assistant ");
            }
            else if (text == "what time it is" || text == "what is the current time" || text == "tell me the current time" || text == "tell the time")
            {
                speechsynth1.SpeakAsync("Right now it is " + DateTime.Now.ToLongTimeString());
            }
            else if (text == "tell me date of today" || text == "tell me the date" || text == "tell the date")
            {
                speechsynth1.SpeakAsync("Today is " + DateTime.Now.ToShortDateString());
            }
            else if (text == "open chrome")
            {
                speechsynth1.SpeakAsync("Ok master");
                Process.Start("chrome");
            }
            else if (text == "pause")
            {
                speechsynth1.SpeakAsync("Ok master");
                //Process.Start("chrome");
                change();
            }
            else if (text == "open notepad")
            {
                speechsynth1.SpeakAsync("Ok master");
                Process.Start("notepad");
            }
            else if (text == "open calculator")
            {
                speechsynth1.SpeakAsync("Ok master");
                Process.Start("calc");
            }
            else if (text == "open paint")
            {
                speechsynth1.SpeakAsync("Ok master");
                Process.Start("mspaint");
            }
            else if (text == "shutdown my laptop")
            {
                speechsynth1.SpeakAsync("Ok master");
                Process.Start("shutdown", "/s /t 0");
            }
            else if (text == "close the program" || text == "close" || text == "close program")
            {
                speechsynth1.SpeakAsync("Are you sure master");
                nn = 1;
            }
            else if (text == "yes i am" || text == "yes")
            {
                speechsynth1.SpeakAsync("Good bye master see you later");
                this.close(nn);
                nn = 100;
            }
            else if (text == "open facebook")
            {
                speechsynth1.SpeakAsync("Ok master");
                Process.Start("chrome", "https://www.facebook.com/");
            }
            else if (text == "open youtube")
            {
                speechsynth1.SpeakAsync("Ok master");
                Process.Start("chrome", "https://www.youtube.com/");
            }
            else if (text == "log out")
            {
                speechsynth1.SpeakAsync("Are you sure master");
                nn = 2;
            }
            else if (text == "change voice to female" || text == "change to female")
            {
                speechsynth1.SelectVoiceByHints(VoiceGender.Female);
                speechsynth1.SpeakAsync("Changed master");
            }
            else if (text == "change voice to male" || text == "change to male")
            {
                speechsynth1.SelectVoiceByHints(VoiceGender.Male);
                speechsynth1.SpeakAsync("Changed master");
            }
            else if (text == "tell my date of birth" || text == "tell my birthday")
            {
                // SqlConnection conn = new SqlConnection("Data Source=DESKTOP-CU4B5J7;Initial Catalog=smartassistant;Integrated Security=True");
                SqlConnection  conn = new SqlConnection("Data Source=DESKTOP-CU4B5J7;Initial Catalog=projectsmartassistant;Integrated Security=True");
                SqlDataAdapter sda  = new SqlDataAdapter("Select Dateofbirth From Signup where Username='******'", conn);

                DataTable dt = new DataTable();
                conn.Open();
                sda.Fill(dt);
                string p = dt.Rows[0][0].ToString();
                p = p.Replace(" 12:00:00 AM", " ");
                speechsynth1.SpeakAsync(p);
            }
            else if (text == "show commands" || text == "show all commands")
            {
                //speechsynth.SelectVoiceByHints(VoiceGender.Male);
                speechsynth1.SpeakAsync("Ok master");
                this.showcommmand(1);
            }
            else if (text == "hide commands" || text == "hide" || text == "hide all commands")
            {
                //speechsynth.SelectVoiceByHints(VoiceGender.Male);
                speechsynth1.SpeakAsync("Ok master");
                this.showcommmand(2);
            }
            else if (text == "open aiub")
            {
                speechsynth1.SpeakAsync("Ok master");
                Process.Start("chrome", "http://www.aiub.edu/");
                //chattext.Text = "";
            }
            else
            {
                speechsynth1.SpeakAsync("I don't understand master");
            }
        }
Пример #41
0
 private void rec(object s, SpeechRecognizedEventArgs e)
 {
     label1.Text = "You: " + e.Result.Text;
 }
Пример #42
0
 void Sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     Console.Write(e.Result.Text);
     speechText.Text = e.Result.Text;
 }
Пример #43
0
 private void sregEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     throw new NotImplementedException();
 }
Пример #44
0
        protected override void SpeechRecognitionEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            base.SpeechRecognitionEngine_SpeechRecognized(sender, e);

            RecognitionResult result = e.Result;

            if (result.Confidence < 0.6)
            {
                SpeakRepeat();
            }
            else
            {
                string[] command = result.Semantics.Value.ToString().ToLower().Split('.');
                DispatchAsync(() =>
                {
                    switch (command.First())
                    {
                    case "back":
                        MoveBack();
                        break;

                    case "movie":
                        OrderMovie(int.Parse(command.Skip(1).First()));
                        break;

                    case "help":
                        SpeakHelp();
                        break;

                    case "quit":
                        SpeakQuit();
                        Close();
                        break;
                    }
                });
            }
        }
Пример #45
0
        private void speechRecognitionWithDictationGrammar_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            //  MessageBox.Show(e.Result.Text);
            if (txtEmail.Text == "")
            {
                txtEmail.Focus();
                VerifyUserandMovetoSubject(e);
                return;
            }

            //Only if you say this comment the control move to attachment
            if (e.Result.Text.Contains("add attachment to this mail"))
            {
                IsSubjectValid = true;
                txtAttachment.Focus();
                synth.SpeakAsync(string.Format("Please choose a attachment"));
                string folderPath = @"D:\test";
                synth.SpeakAsync(string.Format("We have the following attachments"));

                foreach (string file in Directory.EnumerateFiles(folderPath, "*.txt"))
                {
                    attachemnts.Add(file.Replace("D:\\test\\", "").Replace(".txt", ""));
                }
                if (attachemnts.Count == 0)
                {
                    synth.SpeakAsync(string.Format("Sorry there is no attachment in the folder,Please ask your assistant to add the attachments to the folder"));
                }

                int FileId = 1;
                foreach (var attachFile in attachemnts)
                {
                    synth.SpeakAsync(string.Format(FileId.ToString()));
                    synth.SpeakAsync(string.Format(attachFile));
                    FileId++;
                }

                if (attachemnts.Count > 0)
                {
                    synth.SpeakAsync(string.Format("Please choose any of the attachment"));
                }



                if (txtAttachment.Text == "")
                {
                    txtAttachment.Focus();
                }
                else
                {
                    synth.Speak(string.Format("You choosed the attachment {0}", txtAttachment.Text));
                }

                return;
            }



            if (!IsSubjectValid)
            {
                if (txtSubject.Focus() == true)
                {
                    txtSubject.Text = e.Result.Text.ToString();
                    synth.Speak(string.Format("you told {0} as the subject", txtSubject.Text));
                    return;
                }
            }


            if (IsSubjectValid && txtAttachment.Text == "")
            {
                foreach (var attachFile in attachemnts)
                {
                    if (e.Result.Text.ToLower().Contains(attachFile.ToLower()))
                    {
                        if (txtAttachment.Text == "")
                        {
                            txtAttachment.Text = attachFile;
                            if (IsSubjectValid && txtAttachment.Text != "")
                            {
                                synth.Speak(string.Format("you told {0} as the attachment", txtAttachment.Text));
                                txtAttachment.Text = e.Result.Text.ToString();
                                synth.Speak(string.Format("Please tell me the body for this mail", e.Result.Text));
                                richTextBox1.Focus();
                                IsAttachmentValid = true;
                                return;
                            }
                        }
                        else
                        {
                            txtAttachment.Text = "";
                        }
                    }
                }
            }



            if (e.Result.Text.ToLower().Contains("sent mail") || e.Result.Text.ToLower().Contains("ok") && txtEmail.Text != "" && richTextBox1.Text != "")
            {
                if (richTextBox1.Text == "")
                {
                    richTextBox1.Focus();
                    return;
                }

                SentMail();
                //synth.SpeakAsync(string.Format("Mail sent sucessfully"));
                _recognizer.Dispose();
                this.Close();
                return;
            }



            if (IsAttachmentValid)
            {
                synth.Speak(string.Format("you told {0} as the body", e.Result.Text));
                richTextBox1.Text = e.Result.Text.ToString();
                synth.Speak(string.Format("Please say ok or sent mail to sent this mail", e.Result.Text));
                btnSent.Focus();
            }
        }
Пример #46
0
 void ears_HeardSomething(object sender, SpeechRecognizedEventArgs e)
 {
     //this will trigger when something is "heard"
     SaySomething("You said: " + e.Result.Text); //DEBUG
     ProcessInput(e);                            //Send it for anaysis
 }
Пример #47
0
 private static void SpeechRecognizedHandler(object sender, SpeechRecognizedEventArgs e)
 {
     Console.WriteLine("Recognized Handler: " + e?.Result);
 }
Пример #48
0
 private static void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     Console.WriteLine("Recognized text: " + e.Result.Text);
 }
Пример #49
0
        private void myVoice_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            string input = e.Result.Text;

            Console.WriteLine(input);

            switch (input.ToUpper())
            {
            case ("HOW IS THE WEATHER"):
            case ("WEATHER"):
            case ("HOWS THE WEATHER"):
            case ("HOW'S THE WEATHER"):
                getWeather();
                break;

            case ("TOMORROWS FORECAST"):
            case ("TOMORROWS WEATHER"):
            case ("HOWS TOMORROWS WEATHER"):
            case ("HOW IS TOMORROWS WEATHER"):
            case ("WHATS TOMORROW LIKE"):
            case ("WHATS IT LIKE TOMORROW"):
            case ("FORECAST"):
                getForecast();
                break;

            case ("MAIL"):
            case ("EMAIL"):
            case ("EMAILS"):
            case ("OPEN MAIL"):
            case ("OPEN EMAIL"):
            case ("OUTLOOK"):
            case ("SHOW MAIL"):
            case ("SHOW EMAIL"):
            case ("SHOW EMAILS"):
                openMail();
                break;

            case ("SEND MAIL"):
            case ("SEND EMAIL"):
            case ("SEND EMAILS"):
            case ("SEND AN EMAIL"):
            case ("SEND MESSAGE"):
                sendMail();
                break;

            case ("READ MAIL"):
            case ("READ EMAIL"):
            case ("READ EMAILS"):
                readMail();
                break;

            case ("SEARCH"):
            case ("SEARCH FOR"):
            case ("FIND"):
                search();
                break;

            //Works with no appointments - Haven't checked when appointment is present
            case ("CALENDER"):
            case ("CHECK CALENDER"):
            case ("APPOINTMENTS"):
            case ("TASKS"):
                Console.WriteLine("Calender");
                checkCalender();
                break;

            case ("GOOGLE"):
                googleSearch();
                break;

            case ("SHOW TIME"):
            case ("TIME"):
            case ("CURRENT TIME"):
            case ("TELL TIME"):
            case ("SAY TIME"):
                currentTime();
                break;

            case ("SHOW DAY"):
            case ("DAY"):
            case ("CURRENT DAY"):
            case ("TELL DAY"):
            case ("SAY DAY"):
            case ("SHOW DATE"):
            case ("DATE"):
            case ("CURRENT DATE"):
            case ("TELL DATE"):
            case ("SAY DATE"):
                currentDate();
                break;

            case ("HELLO"):
            case ("HEY JARVIS"):
            case ("HEY"):
            case ("SUP"):
            case ("GOOD MORNING"):
            case ("GOOD AFTERNOON"):
            case ("GOOD EVENING"):
                helloResponse();
                break;

            case ("PLAY"):
            case ("PLAY ITUNES"):
            case ("PLAY SONG"):
                app = new iTunesApp();
                app.Play();
                break;

            case ("PAUSE"):
            case ("PAUSE ITUNES"):
            case ("PAUSE SONG"):
                app = new iTunesApp();
                app.Pause();
                break;

            case ("NEXT"):
            case ("NEXT SONG"):
                app = new iTunesApp();
                app.NextTrack();
                app.Play();
                break;

            case ("PREVIOUS"):
            case ("PREVIOUS SONG"):
            case ("LAST SONG"):
                app = new iTunesApp();
                app.PreviousTrack();
                app.Play();
                break;

            case ("SHUFFLE"):
            case ("SHUFFLE ITUNES"):
                app = new iTunesApp();
                app.CurrentPlaylist.Shuffle = true;
                app.Play();
                break;

            case ("TURN DOWN VOLUME"):
            case ("TURN DOWN ITUNES"):
            case ("TURN DOWN SONG VOLUME"):
            case ("TURN DOWN THE VOLUME"):
            case ("TURN DOWN THE SONG VOLUME"):
            case ("TURN DOWN"):
            case ("VOLUME DOWN"):
                turnDownItunes();
                break;

            case ("TURN UP VOLUME"):
            case ("TURN UP ITUNES"):
            case ("TURN UP SONG VOLUME"):
            case ("TURN UP THE VOLUME"):
            case ("TURN UP THE SONG VOLUME"):
            case ("TURN UP"):
            case ("VOLUME UP"):
                turnUpItunes();
                break;

            case ("LEAGUE OF LEGENDS"):
            case ("LOL"):
            case ("LEAGUE"):
                Process.Start(@"C:\Riot Games\League of Legends\lol.launcher.exe");
                break;

            case ("LOLESPORTS"):
            case ("LOL ESPORTS"):
            case ("WATCH LEAGUE"):
                Process.Start("http://euw.lolesports.com/");
                Thread loadLeague = new Thread(new ThreadStart(() => speak.loading()));
                loadLeague.IsBackground = true;
                loadLeague.Start();
                break;

            case ("JARVIS QUIET"):
            case ("JARVIS SH"):
            case ("JARVIS VOLUME DOWN"):
                jarvisVolume(true);
                break;

            case ("JARVIS LOUD"):
            case ("I CANT HEAR YOU"):
            case ("I CANT HEAR YOU JARVIS"):
            case ("JARVIS VOLUME UP"):
                jarvisVolume(false);
                break;

            case ("JARVIS MUTE"):
            case ("MUTE"):
                jarvisMute(true);
                break;

            case ("JARVIS SPEAK"):
            case ("UNDO MUTE"):
                jarvisMute(false);
                break;

            case ("STOP LISTENING"):
                stopListening();
                break;

            case ("EXIT CHROME"):
            case ("CLOSE CHROME"):
                exitChromeWindows();
                break;

            case ("OPEN CHROME"):
                openChromeWindow();
                break;

            case ("ALL PROCESSES"):
            case ("SHOW PROCESSES"):
                showProcesses();
                break;

            case ("CLOSE MAIL"):
            case ("EXIT MAIL"):
            case ("CLOSE OUTLOOK"):
            case ("EXIT OUTLOOK"):
                closeEmail();
                break;

            case ("CLOSE ITUNES"):
            case ("EXIT ITUNES"):
                endProcess("itunes");
                break;

            case ("MOVIES"):
                loadMovies();
                break;

            case ("MINIMIZE"):
            case ("JARVIS SMALL"):
                minimize();
                break;

            case ("JARVIS COME BACK"):
            case ("JARVIS NORMAL"):
            case ("NORMAL"):
                normalSize();
                break;

            case ("QUIT"):
            case ("Q"):
            case ("STOP"):
            case ("END"):
                endProgram(this);
                break;

            default:
                noCommand();
                break;
            }
        }
        private void _recognizeSpeechAndWriteToConsole_SpeechRecognized_Main1(object sender, SpeechRecognizedEventArgs e)
        {
            string itemContent = string.Format(
                CultureInfo.CurrentCulture,
                "Item Content: {0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}",
                "Curabitur class aliquam vestibulum nam curae maecenas sed integer cras phasellus suspendisse quisque donec dis praesent accumsan bibendum pellentesque condimentum adipiscing etiam consequat vivamus dictumst aliquam duis convallis scelerisque est parturient ullamcorper aliquet fusce suspendisse nunc hac eleifend amet blandit facilisi condimentum commodo scelerisque faucibus aenean ullamcorper ante mauris dignissim consectetuer nullam lorem vestibulum habitant conubia elementum pellentesque morbi facilisis arcu sollicitudin diam cubilia aptent vestibulum auctor eget dapibus pellentesque inceptos leo egestas interdum nulla consectetuer suspendisse adipiscing pellentesque proin lobortis sollicitudin augue elit mus congue fermentum parturient fringilla euismod feugiat");

            //MessageBox.Show("DATA IS:" + e.Result.Text);
            PromptBuilder builder1 = new PromptBuilder();

            QNS.Text = e.Result.Text;
            if (e.Result.Text == "MUSIC PLAYER" && main_flag == 1)
            {
                SampleDataItem sampleDataItem = new SampleDataItem(
                    "Group-1-Item-5",
                    "MUSIC PLAYER",
                    string.Empty,
                    null,
                    "MUSIC PLAYER",
                    itemContent,
                    null,
                    typeof(Window1));
                main_flag = 0;
                if (sampleDataItem != null && sampleDataItem.NavigationPage != null)
                {
                    backButton.Visibility    = System.Windows.Visibility.Visible;
                    navigationRegion.Content = Activator.CreateInstance(sampleDataItem.NavigationPage);
                }
            }
            else if (e.Result.Text == "TASK" && main_flag == 0)
            {
                SampleDataItem sampleDataItem = new SampleDataItem(
                    "Group-1-Item-2",
                    "REMINDER",
                    string.Empty,
                    null,
                    "CheckBox and RadioButton controls",
                    itemContent,
                    null,
                    typeof(Page1));
                main_flag = 0;
                if (sampleDataItem != null && sampleDataItem.NavigationPage != null)
                {
                    backButton.Visibility    = System.Windows.Visibility.Visible;
                    navigationRegion.Content = Activator.CreateInstance(sampleDataItem.NavigationPage);
                }
            }
            else if (e.Result.Text == "HELLO")
            {
                builder1.StartSentence();
                // builder1.AppendText("Hello sir ...");
                builder1.EndSentence();
                SpeechSynthesizer synthesizer = new SpeechSynthesizer();
                synthesizer.Speak(builder1);
                synthesizer.Dispose();
            }
            else if (e.Result.Text == "HOME AUTOMATION" && main_flag == 0)
            {
                SampleDataItem sampleDataItem = new SampleDataItem(
                    "Group-1-Item-1",
                    "HOME AUTOMATION",
                    string.Empty,
                    null,
                    "Several types of buttons with custom styles",
                    itemContent,
                    null,
                    typeof(ButtonSample));
                main_flag = 0;
                if (sampleDataItem != null && sampleDataItem.NavigationPage != null)
                {
                    backButton.Visibility    = System.Windows.Visibility.Visible;
                    navigationRegion.Content = Activator.CreateInstance(sampleDataItem.NavigationPage);
                }
            }

            else if (e.Result.Text == "OPEN YOUTUBE" && main_flag == 0)
            {
                main_flag = 0;
                Process.Start("chrome.exe", "http:\\www.YouTube.com");
            }
        }
        void recEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            foreach (KeyValuePair <string, long> entry in numberTable)
            {
                if (entry.Key.Equals(e.Result.Text))
                {
                    double tempResult = 0;
                    if (isDecimalNumber)
                    {
                        inputBox.Text  += entry.Value;
                        nextExpression += entry.Value;
                    }
                    else if (entry.Value < 10)
                    {
                        if (processingNumber4 == 0)
                        {
                            processingNumber4 = entry.Value;
                        }
                        processingNumber = entry.Value;
                        nextExpression   = (double.Parse(nextExpression) + entry.Value).ToString();
                    }
                    else if (entry.Value >= 10 && entry.Value < 100)
                    {
                        processingNumber2 = entry.Value;
                        nextExpression    = (double.Parse(nextExpression) + processingNumber2).ToString();
                    }
                    else if (entry.Value >= 100 && entry.Value < 1000)
                    {
                        processingNumber4 *= entry.Value;
                        processingNumber3  = processingNumber4;
                        if (((double.Parse(nextExpression) - processingNumber) % 1000) == 0)
                        {
                            nextExpression = ((double.Parse(nextExpression) - processingNumber) + processingNumber3).ToString();
                        }
                        else
                        {
                            nextExpression = processingNumber3.ToString();
                        }
                        processingNumber = 0;
                    }
                    else if (entry.Value >= 1000)
                    {
                        tempResult        = (processingNumber + processingNumber2 + processingNumber3) * entry.Value;
                        temporaryOperand += tempResult;
                        nextExpression    = temporaryOperand.ToString();
                        tempResult        = 0;
                        processingNumber  = 0;
                        processingNumber2 = 0;
                        processingNumber3 = 0;
                        processingNumber4 = 0;
                    }
                    inputBox.Text = currentExpression + nextExpression;
                }
            }
            switch (e.Result.Text)
            {
            case "plus":
                resetExpressionCharacteristics("+");
                break;

            case "minus":
                resetExpressionCharacteristics("-");
                break;

            case "times":
                resetExpressionCharacteristics("*");
                break;

            case "divided by":
                resetExpressionCharacteristics(":");
                break;

            case "open bracket":
                resetExpressionCharacteristics("(");
                break;

            case "close bracket":
                resetExpressionCharacteristics(")");
                break;

            case "point":
                isDecimalNumber = true;
                nextExpression += ",";
                inputBox.Text   = currentExpression + nextExpression;
                break;

            case "equals":
                resetExpressionData();
                currentExpression = "";
                nextExpression    = "0";
                btnEquals_Click(btnEquals, EventArgs.Empty);
                break;

            case "clear":
                resetExpressionData();
                currentExpression = "";
                nextExpression    = "0";
                btnDeleteAll_Click(btnDeleteAll, EventArgs.Empty);
                break;

            case "mute":
                btnMute_Click(btnMute, EventArgs.Empty);
                break;

            default:
                break;
            }
        }
Пример #52
0
        private void sRecognize_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            if (exitCondition)
            {
                Thread.Sleep(100);
                if (e.Result.Text == "yes")
                {
                    sSynth.SpeakAsyncCancelAll();
                    sRecognize.RecognizeAsyncCancel();
                    Application.Exit();

                    return;
                }
                else
                {
                    exitCondition = false; speakText("Exit Cancelled"); return;
                }
            }
            switch (e.Result.Text)
            {
            case "hello":
                listBox2.Items.Add(e.Result.Text.ToString());
                speakText("Hello " + Environment.UserName.ToString());
                break;

            case "invisable":
                if (ActiveForm.Visible == true)
                {
                    listBox2.Items.Add(e.Result.Text.ToString());
                    ActiveForm.ShowInTaskbar = false; ActiveForm.Hide();


                    speakText("I am now invisible. You can access me by clicking on the icon down here in the tray.");
                    break;
                }
                else
                {
                    break;
                }

            case "hi":
                listBox2.Items.Add(e.Result.Text.ToString());
                speakText("Hello, " + Environment.UserName.ToString());
                break;

            case "exit":
                listBox2.Items.Add(e.Result.Text.ToString());
                speakText("Are you sure you want to exit?");

                exitCondition = true;
                break;

            case "thank you":
                listBox2.Items.Add(e.Result.Text.ToString());
                speakText("You're welcome");
                break;

            case "stop talking":
                listBox2.Items.Add(e.Result.Text.ToString());
                cancelSpeech();
                break;

            case "lock computer":
                listBox2.Items.Add(e.Result.Text.ToString());
                lockComputer();
                break;



            case "be quiet":
                listBox2.Items.Add(e.Result.Text.ToString());
                cancelSpeech();
                sSynth.SpeakAsyncCancelAll();
                break;

            case "internet":
                listBox2.Items.Add(e.Result.Text.ToString());
                speakText("One moment.");
                Process pr = new Process();
                pr.StartInfo.FileName = "http://www.google.com/";
                pr.Start();
                break;

            case "stop listening":
                listBox2.Items.Add(e.Result.Text.ToString());
                speakText("Ok.");
                sRecognize.RecognizeAsyncCancel();
                sRecognize.RecognizeAsyncStop();

                break;

            case "hide":
                break;
            }
        }
Пример #53
0
        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)
                {
                    sSynth.SpeakAsync("Hello sir");
                }
                else if (ranNum > 5)
                {
                    sSynth.SpeakAsync("Hi");
                }
                break;

            case "goodbye":
            case "goodbye jarvis":
            case "close":
            case "close jarvis":
                sSynth.SpeakAsync("Until next time");
                Close();
                break;

            case "jarvis":
                if (ranNum < 5)
                {
                    QEvent = ""; sSynth.SpeakAsync("Yes sir");
                }
                else if (ranNum > 4)
                {
                    QEvent = ""; sSynth.SpeakAsync("Yes?");
                }
                break;

            //WEBSITES
            case "open website":
                System.Diagnostics.Process.Start("url");
                break;

            //SHELL COMMANDS
            case "open program":
                System.Diagnostics.Process.Start("file location");
                sSynth.SpeakAsync("Loading");
                break;

            //CLOSE PROGRAMS
            case "close program":
                ProcWindow = "process name";
                StopWindow();
                break;

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

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

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

            //OTHER COMMANDS
            case "go fullscreen":
                FormBorderStyle = FormBorderStyle.None;
                WindowState     = FormWindowState.Maximized;
                TopMost         = true;
                sSynth.SpeakAsync("expanding");
                break;

            case "exit fullscreen":
                FormBorderStyle = FormBorderStyle.Sizable;
                WindowState     = FormWindowState.Normal;
                TopMost         = false;
                break;

            case "switch window":
                SendKeys.Send("%{TAB " + count + "}");
                count += 1;
                break;

            case "reset":
                count                 = 1;
                timer                 = 11;
                lblTimer.Visible      = false;
                ShutdownTimer.Enabled = false;
                lstCommands.Visible   = false;
                break;

            case "out of the way":
                if (WindowState == FormWindowState.Normal || WindowState == FormWindowState.Maximized)
                {
                    WindowState = FormWindowState.Minimized;
                    sSynth.SpeakAsync("My apologies");
                }
                break;

            case "come back":
                if (WindowState == FormWindowState.Minimized)
                {
                    sSynth.SpeakAsync("Alright?");
                    WindowState = FormWindowState.Normal;
                }
                break;

            case "show commands":
                string[] commands = (File.ReadAllLines(@"txt file location"));
                sSynth.SpeakAsync("Very well");
                lstCommands.Items.Clear();
                lstCommands.SelectionMode = SelectionMode.None;
                lstCommands.Visible       = true;
                foreach (string command in commands)
                {
                    lstCommands.Items.Add(command);
                }
                break;

            case "hide listbox":
                lstCommands.Visible = false;
                break;
            }
        }
Пример #54
0
        private void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            setLabel("Wait...");
            XmlDocument xmlDoc1   = null;
            XmlNodeList nodeList1 = null;

            if (!skip)
            {
                xmlDoc1 = new XmlDocument();
                xmlDoc1.Load("C:\\Users\\nm045365\\Documents\\voicecommands.xml");
                xpath     = "/data/" + e.Result.Text.ToString().Replace(' ', '/');
                nodeList1 = xmlDoc1.DocumentElement.SelectNodes(xpath);
            }
            else
            {
                Thread.Sleep(5000);
                xmlDoc1 = new XmlDocument();
                xmlDoc1.Load("C:\\Users\\nm045365\\Documents\\voicecommands.xml");
                xpath     = xpath + "/" + e.Result.Text;
                nodeList1 = xmlDoc1.DocumentElement.SelectNodes(xpath);
                skip      = false;
            }
            foreach (XmlNode node in nodeList1)
            {
                if (node.ChildNodes.Count > 1)
                {
                    String option = null;

                    ss.Speak("I can see " + node.ChildNodes.Count + " options");
                    foreach (XmlNode eh in node.ChildNodes)
                    {
                        ss.SpeakAsync(eh.Name + " ");
                        option += eh.Name + "/";
                    }
                    ss.Speak("please select ?");
                    skip = true;

                    String   i = option.Remove(option.Length - 1, 1) + "";
                    String[] g = i.Split('/');

                    Choices clist1 = new Choices();
                    clist1.Add(g);
                    Grammar gr = new Grammar(new GrammarBuilder(clist1));
                    sre.LoadGrammar(gr);
                    setLabel("Listening...");
                }
                else if (node.ChildNodes.Count == 1)
                {
                    String pro = node.FirstChild.InnerText;
                    setLabel("Processing");
                    if (pro.Contains("appointments"))
                    {
                        appointmentsInRange();
                    }
                    else if (pro.Contains("see you later"))
                    {
                        ss.Speak(pro);
                    }
                    else if (pro.Contains("environment"))
                    {
                        MessageBox.Show("hi");
                        Form3 f3 = new Form3();
                        f3.Show();
                    }
                    else if (pro.Contains("selectPatient"))
                    {
                        selectPatient();
                    }
                    else
                    {
                        System.Diagnostics.Process.Start(pro);
                    }
                }
                setLabel("Ask me");
            }
        }
Пример #55
0
        void sr_debug(object sender, SpeechRecognizedEventArgs e)
        {
            RecognitionResult r = e.Result;

            Console.WriteLine(r.Text);
        }
Пример #56
0
        void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            if (e.Result.Confidence < 0.55)
            {
                Trace.WriteLine("\nSpeech Rejected filtered, confidence: " + e.Result.Confidence);
                return;
            }

            Trace.WriteLine("\nSpeech Recognized, confidence: " + e.Result.Confidence + ": \t{0}", e.Result.Text);

            if (e.Result.Text == "show window")
            {
                this.Dispatcher.BeginInvoke((Action) delegate
                {
                    ShowWindow();
                });
            }
            else if (e.Result.Text == "hide window")
            {
                this.Dispatcher.BeginInvoke((Action) delegate
                {
                    HideWindow();
                });
            }
            else if (e.Result.Text == "next slide")
            {
                System.Windows.Forms.SendKeys.SendWait("{Right}");
            }
            else if (e.Result.Text == "previous slide")
            {
                System.Windows.Forms.SendKeys.SendWait("{Left}");
            }
            else if (e.Result.Text == "close window")
            {
                this.Close();
            }
            else if (e.Result.Text == "Start seated mode" || e.Result.Text == "Start near mode")
            {
                cb1.IsChecked = true;
                sensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;
                sensor.SkeletonStream.EnableTrackingInNearRange = true;
            }
            else if (e.Result.Text == "Stop seated mode" || e.Result.Text == "Stop near mode")
            {
                cb1.IsChecked = false;
                sensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Default;
                sensor.SkeletonStream.EnableTrackingInNearRange = false;
            }
            else if (e.Result.Text == "Mouse on")
            {
                if (closestSkeleton.TrackingState == SkeletonTrackingState.Tracked)
                {
                    mouse   = true;
                    originX = closestSkeleton.Joints[JointType.ShoulderCenter].Position.X;
                    originY = closestSkeleton.Joints[JointType.ShoulderCenter].Position.Y;
                    x[0]    = x[1] = x[2] = closestSkeleton.Joints[JointType.HandRight].Position.X;
                    y[0]    = y[1] = y[2] = closestSkeleton.Joints[JointType.HandRight].Position.Y;
                    Trace.WriteLine("Mouse Mode ON");
                }
                else
                {
                    mouse = false;
                    Trace.WriteLine("No skeleton found.");
                    MessageBox.Show("No skeleton found. Are you there?");
                }
            }
            else if (e.Result.Text == "Mouse off")
            {
                mouse = false;
                Trace.WriteLine("Mouse Mode OFF");
            }
            else if (e.Result.Text == "drag")
            {
                mouse_event(MOUSEEVENTF_LEFTDOWN, System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y, 0, 0);
            }
            else if (e.Result.Text == "drop")
            {
                mouse_event(MOUSEEVENTF_LEFTUP, System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y, 0, 0);
            }
            else if (e.Result.Text == "left")
            {
                mouse_event(MOUSEEVENTF_LEFTDOWN, System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y, 0, 0);
                mouse_event(MOUSEEVENTF_LEFTUP, System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y, 0, 0);
            }
            else if (e.Result.Text == "right")
            {
                mouse_event(MOUSEEVENTF_RIGHTDOWN, System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y, 0, 0);

                mouse_event(MOUSEEVENTF_RIGHTUP, System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y, 0, 0);
            }
            else if (e.Result.Text == "open")
            {
                mouse_event(MOUSEEVENTF_LEFTDOWN, System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y, 0, 0);
                mouse_event(MOUSEEVENTF_LEFTUP, System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y, 0, 0);
                Thread.Sleep(100);
                mouse_event(MOUSEEVENTF_LEFTDOWN, System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y, 0, 0);
                mouse_event(MOUSEEVENTF_LEFTUP, System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y, 0, 0);
            }
            else if (e.Result.Text == "Close Application")
            {
                System.Windows.Forms.SendKeys.SendWait("%{F4}");
            }
            else if (e.Result.Text == "Back")
            {
                System.Windows.Forms.SendKeys.SendWait("%{LEFT}");
            }
            else if (e.Result.Text == "Forward")
            {
                System.Windows.Forms.SendKeys.SendWait("%{RIGHT}");
            }
            else if (e.Result.Text == " Page Up")
            {
                System.Windows.Forms.SendKeys.SendWait("{PGUP}");
            }
            else if (e.Result.Text == "Page Down")
            {
                System.Windows.Forms.SendKeys.SendWait("{PGDN}");
            }
            else if (e.Result.Text == "Switch Tab")
            {
                System.Windows.Forms.SendKeys.SendWait("%{TAB}");
            }
            else if (e.Result.Text == "Tab")
            {
                System.Windows.Forms.SendKeys.SendWait("{TAB}");
            }
            else if (e.Result.Text == "Select All")
            {
                System.Windows.Forms.SendKeys.SendWait("^{A}");
            }
            else if (e.Result.Text == "Copy")
            {
                System.Windows.Forms.SendKeys.SendWait("^{C}");
            }
            else if (e.Result.Text == "Cut")
            {
                System.Windows.Forms.SendKeys.SendWait("^{X}");
            }
            else if (e.Result.Text == "Paste")
            {
                System.Windows.Forms.SendKeys.SendWait("^{V}");
            }
            else if (e.Result.Text == "Reload")
            {
                System.Windows.Forms.SendKeys.SendWait("^{R}");
            }
            else if (e.Result.Text == "Undo")
            {
                System.Windows.Forms.SendKeys.SendWait("^{Z}");
            }
            else if (e.Result.Text == "Redo")
            {
                System.Windows.Forms.SendKeys.SendWait("^{Y}");
            }
            else if (e.Result.Text == "Zoom In")
            {
                System.Windows.Forms.SendKeys.SendWait("^{ADD}");
            }
            else if (e.Result.Text == "Zoom Out")
            {
                System.Windows.Forms.SendKeys.SendWait("^{SUBTRACT}");
            }
            else if (e.Result.Text == "Num Lock")
            {
                System.Windows.Forms.SendKeys.SendWait("{NUMLOCK}");
            }
            else if (e.Result.Text == "Caps Lock")
            {
                System.Windows.Forms.SendKeys.SendWait("{CAPSLOCK}");
            }
            else if (e.Result.Text == "Scroll Lock")
            {
                System.Windows.Forms.SendKeys.SendWait("{SCROLLLOCK}");
            }
            else if (e.Result.Text == "Backspace")
            {
                System.Windows.Forms.SendKeys.SendWait("{BS}");
            }
            else if (e.Result.Text == "Break")
            {
                System.Windows.Forms.SendKeys.SendWait("{BREAK}");
            }
            else if (e.Result.Text == "Delete")
            {
                System.Windows.Forms.SendKeys.SendWait("{DEL}");
            }
            else if (e.Result.Text == "Delete Permanently")
            {
                System.Windows.Forms.SendKeys.SendWait("+{DEL}");
            }
            else if (e.Result.Text == "Up")
            {
                System.Windows.Forms.SendKeys.SendWait("{UP}");
            }
            else if (e.Result.Text == "Down")
            {
                System.Windows.Forms.SendKeys.SendWait("{DOWN}");
            }
            else if (e.Result.Text == "Right")
            {
                System.Windows.Forms.SendKeys.SendWait("{RIGHT}");
            }
            else if (e.Result.Text == "Left")
            {
                System.Windows.Forms.SendKeys.SendWait("{LEFT}");
            }
            else if (e.Result.Text == "End")
            {
                System.Windows.Forms.SendKeys.SendWait("{END}");
            }
            else if (e.Result.Text == "Enter")
            {
                System.Windows.Forms.SendKeys.SendWait("{ENTER}");
            }
            else if (e.Result.Text == "Home")
            {
                System.Windows.Forms.SendKeys.SendWait("{HOME}");
            }
            else if (e.Result.Text == "Escape")
            {
                System.Windows.Forms.SendKeys.SendWait("{ESC}");
            }
            else if (e.Result.Text == "Help")
            {
                System.Windows.Forms.SendKeys.SendWait("{HELP}");
            }
            else if (e.Result.Text == "Insert")
            {
                System.Windows.Forms.SendKeys.SendWait("{INS}");
            }
            else if (e.Result.Text == "Add")
            {
                System.Windows.Forms.SendKeys.SendWait("{ADD}");
            }
            else if (e.Result.Text == "Subtract")
            {
                System.Windows.Forms.SendKeys.SendWait("{SUBTRACT}");
            }
            else if (e.Result.Text == "Multiply")
            {
                System.Windows.Forms.SendKeys.SendWait("{MULTIPLY}");
            }
            else if (e.Result.Text == "Divide")
            {
                System.Windows.Forms.SendKeys.SendWait("{DIVIDE}");
            }
            else if (e.Result.Text == "Shift")
            {
                System.Windows.Forms.SendKeys.SendWait("{+}");
            }
            else if (e.Result.Text == "Control")
            {
                System.Windows.Forms.SendKeys.SendWait("{^}");
            }
            else if (e.Result.Text == "Alt")
            {
                System.Windows.Forms.SendKeys.SendWait("{%}");
            }
            else if (e.Result.Text == "Print")
            {
                System.Windows.Forms.SendKeys.SendWait("^{P}");
            }
            else if (e.Result.Text == "Save")
            {
                System.Windows.Forms.SendKeys.SendWait("^{S}");
            }
            else if (e.Result.Text == "Windows")
            {
                System.Windows.Forms.SendKeys.SendWait("^{ESC}");
            }
            else if (e.Result.Text == "Print Screen")
            {
                System.Windows.Forms.SendKeys.SendWait("^{ESCPRTSC}");
            }
            else if (e.Result.Text == "Open Task Manager")
            {
                System.Windows.Forms.SendKeys.SendWait("^+{ESC}");
            }
            else if (e.Result.Text == "Select Right")
            {
                System.Windows.Forms.SendKeys.SendWait("+{RIGHT}");
            }
            else if (e.Result.Text == "Select Left")
            {
                System.Windows.Forms.SendKeys.SendWait("+{LEFT}");
            }
            else if (e.Result.Text == "Change Tab")
            {
                System.Windows.Forms.SendKeys.SendWait("^{TAB}");
            }
            else if (e.Result.Text == "Open Search")
            {
                System.Windows.Forms.SendKeys.SendWait("^{F}");
            }
            else if (e.Result.Text == "New Browser Window")
            {
                System.Windows.Forms.SendKeys.SendWait("^{N}");
            }
            else if (e.Result.Text == "Close Browser Window")
            {
                System.Windows.Forms.SendKeys.SendWait("^{W}");
            }
            else if (e.Result.Text == "New Folder")
            {
                System.Windows.Forms.SendKeys.SendWait("^+{N}");
            }
            else if (e.Result.Text == "Properties")
            {
                System.Windows.Forms.SendKeys.SendWait("%{ENTER}");
            }
        }
Пример #57
0
        public void _recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            textBox1.Text = urlText;


            string word;

            String[] colors = new String[3];

            DateTimeFormatInfo fmt = (new CultureInfo("pl-PL")).DateTimeFormat;

            string speech = e.Result.Text;

            richTextBox1.Text = e.Result.Text;

            if (speech == "wake")
            {
                wake = true;
            }
            if (speech == "sleep")
            {
                wake = false;
            }

            /*  Random random = new Random();
             * int value = random.Next(1, 10);
             *
             *    colors[0] = "Green";
             *    colors[1] = "Blue";
             *    colors[2] = "Red";
             *
             * if (speech == "jarvis your color?" && value <=3)
             *    {
             *     Mow("My favorite color is:" + colors[0]);
             * }else if (speech == "jarvis your color?" && value == 5)
             * {
             *    Mow("My favorite color is:" + colors[1]);
             * }else if (speech == "jarvis your color?" && value >= 7)
             * {
             *    Mow("My favorite color is:" + colors[2]);
             * }
             */
            String[] linie = new String[13];

            for (int i = 0; i < 1; i++)
            {
                using (StreamReader reader = new StreamReader(Application.StartupPath + "\\wyrazy_jarvis.txt"))
                {
                    linie[0]  = reader.ReadLine();
                    linie[1]  = reader.ReadLine();
                    linie[2]  = reader.ReadLine();
                    linie[3]  = reader.ReadLine();
                    linie[4]  = reader.ReadLine();
                    linie[5]  = reader.ReadLine();
                    linie[6]  = reader.ReadLine();
                    linie[7]  = reader.ReadLine();
                    linie[8]  = reader.ReadLine();
                    linie[9]  = reader.ReadLine();
                    linie[10] = reader.ReadLine();
                    linie[11] = reader.ReadLine();
                    linie[12] = reader.ReadLine();
                }



                if (speech == (linie[0]) || speech == (linie[9]) || speech == (linie[10]))
                {
                    Mow("Witam" + imie);
                }

                if (speech == linie[1])
                {
                    Mow("Jarvis uruchamia Facebook");
                    System.Diagnostics.Process.Start("http://www.facebook.com");
                }

                if (speech == linie[2])
                {
                    Mow("Dziękuję dobrze, miło że pytasz Sir");
                }
                if (speech == linie[3])
                {
                    Mow("Jarvis uruchamia kantor");
                    System.Diagnostics.Process.Start("https://internetowykantor.pl/kurs-euro/");
                    Mow("Kantor prezentuje kurs walut wraz z wykresami");
                }

                if (speech == linie[4])
                {
                    Mow("Wyszukuję Informacje");
                    if (linie[4].Contains("zginelo"))
                    {
                        word = "zginęło";
                        string s = "https://pl.wikipedia.org/wiki/RMS_Titanic";

                        string          pageContent = null;
                        HttpWebRequest  myReq       = (HttpWebRequest)WebRequest.Create(s);
                        HttpWebResponse myres       = (HttpWebResponse)myReq.GetResponse();


                        using (StreamReader sr = new StreamReader(myres.GetResponseStream()))
                        {
                            pageContent = sr.ReadToEnd();
                        }

                        if (pageContent.Contains(word))
                        {
                            Mow(getBetween(pageContent, word, "."));
                        }
                        else
                        {
                            Mow("brak Informacji");
                        }
                    }
                }
                if (speech == linie[5])
                {
                    Mow(DateTime.Now.ToString("t", fmt));
                }
                if (speech == linie[6])
                {
                    Mow(DateTime.Now.ToString("d", fmt));
                }
                if (speech == linie[7])
                {
                    Mow("Przyjemność po mojej stronie Sir");
                }

                string[] linki = File.ReadAllLines(sciezka);
                Random   rsong = new Random();
                Console.WriteLine(linki[rsong.Next(linki.Length)]);

                if (speech == linie[8])
                {
                    Mow("Jarvis wybiera piosenkę");
                    System.Diagnostics.Process.Start(linki[rsong.Next(linki.Length)]);
                }
                if (speech == linie[11])
                {
                    string urlAdress = textBox1.Text;


                    Mow("Jarvis wyszukuje wybrane słowo");
                    WebBrowser browser = new WebBrowser();

                    browser.Navigate("https://www.google.pl/search?q=" + speech);
                }
            }

            if (speech == "light on")
            {
                port.Open();
                port.WriteLine("A");
                port.Close();
            }
            if (speech == "light off")
            {
                port.Open();
                port.WriteLine("B");
                port.Close();
            }
        }
Пример #58
0
 void sr_Speech(object sender, SpeechRecognizedEventArgs e)
 {
     MessageBox.Show(e.Result.Text);
 }
Пример #59
0
        private void Sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            // ignore while the assistant is speaking
            if (assistantSpeaking)
            {
                return;
            }

            // ignore low confidance levels
            if (e.Result.Confidence < 0.4)
            {
                return;
            }

            // if confidence is between 40% and 60%
            if (e.Result.Confidence <= 0.6)
            {
                Speak("Desculpa, não consegui entender. Repete por favor..", 5);
                return;
            }

            // TO DOOOOOOOOOOOOOOOO
            // if confidence is between 60% and 80%, confirm explicitly

            /*if (e.Result.Confidence <= 0.80)
             * {
             *  Speak("Confirmar resposta..." , 2);
             * }*/

            onRecognized(new SpeechEventArg()
            {
                Text = e.Result.Text, Confidence = e.Result.Confidence, Final = true, AssistantSpeaking = assistantSpeaking
            });

            // SEND
            // IMPORTANT TO KEEP THE FORMAT {"recognized":["SHAPE","COLOR"]}
            string json = "{ \"recognized\": [";

            foreach (var resultSemantic in e.Result.Semantics)
            {
                json += "\"" + resultSemantic.Value.Value + "\", ";
            }
            json  = json.Substring(0, json.Length - 2);
            json += "] }";

            if (json.Contains("SEARCH"))
            {
                searchDone = true;
                Speak("Estou a pesquisar, só um segundo..", 2);
            }

            if (json.Contains("HOTEL"))
            {
                searchDone = true;
            }

            if (json.Contains("FILTER") && !searchDone)
            {
                Speak("É necessário definir um destino para pesquisa de hotéis primeiro..", 5);
                return;
            }

            if (json.Contains("HELP"))
            {
                RandomSpeak(new string[] {
                    "Experimenta dizer: Pesquisar voos em Madrid",
                    "Experimenta dizer: Pesquisar alojamento em Roma",
                    "Experimenta dizer: Pesquisar voos para Londres",
                }, 4);
                return;
            }

            if (json.Contains("CLOSE"))
            {
                pendingSemantic = e.Result.Semantics;
                Speak("Tens a certeza que pretendes sair da aplicação ?", 4);
                return;
            }

            // hold sematics from a previous command that is being confirmed or from the current command
            SemanticValue semanticValue = null;

            if (pendingSemantic != null)
            {
                //voice feedback for confirmation
                switch (e.Result.Semantics["action"].Value.ToString())
                {
                case "YES":
                    RandomSpeak(new string[] {
                        "Adeus, até uma próxima! ",
                    }, 4);
                    semanticValue   = pendingSemantic;
                    pendingSemantic = null;

                    json = "{ \"recognized\": [";
                    foreach (var resultSemantic in semanticValue)
                    {
                        json += "\"" + resultSemantic.Value.Value + "\", ";
                    }
                    json  = json.Substring(0, json.Length - 2);
                    json += "] }";

                    var exNot2 = lce.ExtensionNotification(e.Result.Audio.StartTime + "", e.Result.Audio.StartTime.Add(e.Result.Audio.Duration) + "", e.Result.Confidence, json);
                    mmic.Send(exNot2);

                    Console.WriteLine("EXITING PROGRAM!");
                    Environment.Exit(0);
                    break;

                case "NO":
                    pendingSemantic = null;
                    RandomSpeak(new string[] {
                        "Percebi mal, peço desculpa.."
                    }, 4);
                    return;
                }
            }

            var exNot = lce.ExtensionNotification(e.Result.Audio.StartTime + "", e.Result.Audio.StartTime.Add(e.Result.Audio.Duration) + "", e.Result.Confidence, json);

            mmic.Send(exNot);
        }
        void speechengine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            const double igualdad = 0.1;

            if (e.Result.Confidence > igualdad)
            {
                switch (e.Result.Words[0].Text)
                {
                //En caso de que digamos "uno" la llave "UNO" se abrira y se realizara lo siguiente

                case "ENCENDIDO":

                    //Se mandara un mensaje alusivo a la imagen

                    boxMensaje.Text = "encendido";


                    break;

                case "APAGADO":
                    boxMensaje.Text = "apagado";
                    //   sendText.setMessage(boxMensaje.Text);
                    // sendText.sendMessage();
                    break;

                //default:

                //En caso de que no solo contenga una palabra tambien realizaremos un switch para ver si la frase corresponde a alguna de nuestros
                //valores de opcion

                //switch (e.Result.Semantics.Value.ToString())

                //{

                case "ADELANTE":
                    boxMensaje.Text = "adelante";
                    System.Diagnostics.Debug.WriteLine("YOOOOO");
                    //  sendText.setMessage(boxMensaje.Text);
                    //sendText.sendMessage();
                    break;

                case "BACK":
                    boxMensaje.Text = "atras";
                    //  sendText.setMessage(boxMensaje.Text);
                    //sendText.sendMessage();
                    break;

                case "SUBE":
                    boxMensaje.Text = "subeVolumen";
                    //  sendText.setMessage(boxMensaje.Text);
                    //sendText.sendMessage();
                    break;

                case "BAJA":
                    boxMensaje.Text = "bajaVolumen";
//sendText.setMessage(boxMensaje.Text);
//                      sendText.sendMessage();
                    break;

                default:

                    boxMensaje.Text = "No se reconoció el comando";

                    break;

                    //}

                    //break;
                }
            }
        }