private void oRecognizer_SpeechRecognized(object sender, System.Speech.Recognition.SpeechRecognizedEventArgs e)
        {
            RecognitionResult result          = e.Result;
            SemanticValue     semantics       = e.Result.Semantics;
            string            scriptParameter = "";

            if (e.Result.Semantics.ContainsKey("PARAM1"))
            {
                string temp = e.Result.Semantics["PARAM1"].Value.ToString().Replace("'s", "").Replace("'S", "");
                if (temp.ToUpper() == "I" || temp.ToUpper() == "ME" || temp.ToUpper() == "MY")
                {
                    temp = gUser;
                }
                if (temp.ToUpper() == "YOU" || temp.ToUpper() == "YOUR")
                {
                    temp = gSystemName;
                }
                scriptParameter = temp;
                if (e.Result.Semantics.ContainsKey("PARAM2"))
                {
                    temp = e.Result.Semantics["PARAM2"].Value.ToString().Replace("'s", "").Replace("'S", "");
                    if (temp.ToUpper() == "I" || temp.ToUpper() == "ME" || temp.ToUpper() == "MY")
                    {
                        temp = gUser;
                    }
                    if (temp.ToUpper() == "YOU" || temp.ToUpper() == "YOUR")
                    {
                        temp = gSystemName;
                    }
                    scriptParameter += "," + temp;
                    if (e.Result.Semantics.ContainsKey("PARAM3"))
                    {
                        temp = e.Result.Semantics["PARAM3"].Value.ToString().Replace("'s", "").Replace("'S", "");
                        if (temp.ToUpper() == "I" || temp.ToUpper() == "ME" || temp.ToUpper() == "MY")
                        {
                            temp = gUser;
                        }
                        if (temp.ToUpper() == "YOU" || temp.ToUpper() == "YOUR")
                        {
                            temp = gSystemName;
                        }
                        scriptParameter += "," + temp;
                    }
                }
            }
            // scriptParameter = scriptParameter.Replace();


            if (result.Grammar.Name.ToString() == "Direct Match")
            {
                ProcessInput(result.Text, result.Text, scriptParameter);
            }
            else
            {
                ProcessInput(result.Text, result.Grammar.Name.ToString(), scriptParameter);
            }
        }
예제 #2
0
        private void auto_SpeechRecognized(object sender, System.Speech.Recognition.SpeechRecognizedEventArgs e)
        {
            string recogText = "";

            // Capitalize the first letter
            recogText = (e.Result.Text.Substring(0, 1).ToUpper() + (e.Result.Text.Substring(1)));
            this.Text = "KCB Level Detection. Recognised text:" + recogText;
            //if the user speaks "Help me" or "Help me ..something" then the program will read the floor names.
            if (recogText.Substring(0, 7).Equals("Help me") || recogText.Substring(0, 5).Equals("Cindy"))
            {
                speakFloorName(2);
            }
        }
        private void oRecognizer_SpeechRecognized(object sender, System.Speech.Recognition.SpeechRecognizedEventArgs e)
        {
            DataSet dsResults = new DataSet();
            String  sPattern  = "";

            try
            {
                if ((e.Result.Text == gWakePhrase) & (gVRMuted == true))
                {
                    gVRMuted          = false;
                    lblStatus.Content = "I am awake";
                }
                else if ((e.Result.Text == gSleepPhrase) & (gVRMuted == false))
                {
                    gVRMuted          = true;
                    lblStatus.Content = "I am sleeping";
                }
                // gSpeechPlugin;
                String temp = OSAEApi.GetObjectPropertyValue(gSpeechPlugin, "Speaking").Value.ToString().ToLower();

                if (temp.ToLower() == "true")
                {
                    try
                    {
                        AddToLog("Ignored Speech because TTS was talking.");
                    }
                    catch (Exception ex)
                    {
                    }
                }
                else
                {
                    if ((gVRMuted == false) || (e.Result.Text == gSleepPhrase) || (e.Result.Text == gSleepPhrase))
                    {
                        try
                        {
                            string sText = OSAEApi.MatchPattern(e.Result.Text);
                            OSAEApi.MethodQueueAdd("Script Processor", "NAMED SCRIPT", sText, "");
                            AddToLog("Heard: " + e.Result.Text + ", Ran: " + sText);
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                AddToLog("Error in _SpeechRecognized: " + ex.Message);
            }
        }
예제 #4
0
        private void SpeechRecognitionService_SpeechRecognized(System.Speech.Recognition.SpeechRecognizedEventArgs e)
        {
            SemanticValue semantics = e.Result.Semantics;

            if (semantics.ContainsKey(NEW_KEY))
            {
                if (semantics.ContainsKey(LEVEL_KEY))
                {
                    switch (semantics[LEVEL_KEY].Value.ToString())
                    {
                    case "facil":
                        RB_Easy.IsChecked = true;
                        break;

                    case "media":
                        RB_Med.IsChecked = true;
                        break;

                    case "dificil":
                        RB_Hard.IsChecked = true;
                        break;
                    }
                }
                NuevaPartida();
            }
            else if (semantics.ContainsKey(RESTART_KEY))
            {
                ReiniciarPartida();
            }
            else if (semantics.ContainsKey(PROBABLE_KEY))
            {
                CB_VerPosibles.IsChecked = mostrarPosibles = bool.Parse(semantics[PROBABLE_KEY].Value.ToString());
                ActualizaPosibles();
            }
            else
            {
                int newNumber = 0;

                if (semantics.ContainsKey(NUMBER_KEY))
                {
                    newNumber = int.Parse(semantics[NUMBER_KEY].Value.ToString());
                }

                int row    = LEFT_HEADER.IndexOf(semantics["Row"].Value.ToString());
                int column = int.Parse(semantics["Column"].Value.ToString()) - 1;

                PonSelecciónEn(row, column);
                _s[_filaActual, _columnaActual] = newNumber;
            }
        }
예제 #5
0
        private void oRecognizer_SpeechRecognized(object sender, System.Speech.Recognition.SpeechRecognizedEventArgs e)
        {
            try
            {
                RecognitionResult result          = e.Result;
                SemanticValue     semantics       = e.Result.Semantics;
                string            scriptParameter = "";
                if (e.Result.Semantics.ContainsKey("PARAM1"))
                {
                    string temp = e.Result.Semantics["PARAM1"].Value.ToString().Replace("'s", "").Replace("'S", "");
                    if (temp.ToUpper() == "I" || temp.ToUpper() == "ME" || temp.ToUpper() == "MY")
                    {
                        temp = gCurrentUser;
                    }
                    if (temp.ToUpper() == "YOU" || temp.ToUpper() == "YOUR")
                    {
                        temp = "SYSTEM";
                    }
                    scriptParameter = temp;
                    if (e.Result.Semantics.ContainsKey("PARAM2"))
                    {
                        temp = e.Result.Semantics["PARAM2"].Value.ToString().Replace("'s", "").Replace("'S", "");
                        if (temp.ToUpper() == "I" || temp.ToUpper() == "ME" || temp.ToUpper() == "MY")
                        {
                            temp = gCurrentUser;
                        }
                        if (temp.ToUpper() == "YOU" || temp.ToUpper() == "YOUR")
                        {
                            temp = "SYSTEM";
                        }
                        scriptParameter += "," + temp;
                        if (e.Result.Semantics.ContainsKey("PARAM3"))
                        {
                            temp = e.Result.Semantics["PARAM3"].Value.ToString().Replace("'s", "").Replace("'S", "");
                            if (temp.ToUpper() == "I" || temp.ToUpper() == "ME" || temp.ToUpper() == "MY")
                            {
                                temp = gCurrentUser;
                            }
                            if (temp.ToUpper() == "YOU" || temp.ToUpper() == "YOUR")
                            {
                                temp = "SYSTEM";
                            }
                            scriptParameter += "," + temp;
                        }
                    }
                }
                // scriptParameter = scriptParameter.Replace();
                string sResults = "";
                if (e.Result.Semantics.ContainsKey("ANSWER"))
                {
                    Question_Answered(e.Result.Semantics["ANSWER"].Value.ToString());
                }
                else
                {
                    if (result.Grammar.Name.ToString() == "Direct Match")
                    {
                        Log.Debug("Searching for: " + sResults);
                        sResults = OSAEGrammar.SearchForMeaning(result.Text, scriptParameter, gCurrentUser);
                    }
                    else
                    {
                        Log.Debug("Searching for: " + sResults);
                        sResults = OSAEGrammar.SearchForMeaning(result.Grammar.Name.ToString(), scriptParameter, gCurrentUser);
                    }
                }

                Log.Info("Search Results: " + sResults);
            }
            catch (Exception ex)
            { Log.Error("Error in _SpeechRecognized!", ex); }
        }
예제 #6
0
 private static void SreOnSpeechRecognized(object sender, SSR.SpeechRecognizedEventArgs e)
 {
     Console.WriteLine("--------------------");
     Console.WriteLine("Recognized: {0}", e.Result.Text);
     Console.WriteLine("--------------------");
 }
예제 #7
0
 private void oRecognizer_SpeechRecognized(object sender, System.Speech.Recognition.SpeechRecognizedEventArgs e)
 {
     ProcessInput(e.Result.Text);
 }
        private void cindyListens_SpeechRecognized(object sender, System.Speech.Recognition.SpeechRecognizedEventArgs e)
        {
            string recogText = e.Result.Text, temp = "";
            bool   qm = false;

            try
            {
                //if (recogText.Equals("Help me")) cindy("Ok, I am here to assist you.");
                if (recogText.Equals("the time"))
                {
                    sayDetailTime();
                }
                else if (recogText.Equals("No"))
                {
                    cindy("", 0, true);                              //keeps cindy silent.
                }
                else if (recogText.Equals("Todays Weather"))
                {
                    cindy("Sorry, I can't tell weather information at the moment. I am waiting for upgrade", 0, false);
                }
                else if (recogText.Equals("Vibration off"))
                {
                    vibrationOFF();
                }
                else if (recogText.Equals("Vibration on"))
                {
                    vibrationON();
                }
                else if (recogText.Equals("Thank you"))
                {
                    cindy("You are welcome", 0, false);
                }
                else if (recogText.Equals("me a story"))
                {
                    // Quote by Albert Einstein however the speech doesnt read as its supposed to be.
                    cindy("Sorry, I don't know any story but, I have a quote by L-bert i-stien, " +
                          "'Everything should be made as simple as possible, but not simpler'. ", -2, false);
                }
                else if (recogText.Equals("Set range a"))
                {
                    cindy("Ok, i will only be scanning anything on 0.50 meters range.", 0, false);
                    kinectRangeImageSet(1);
                }
                else if (recogText.Equals("Set range b"))
                {
                    cindy("Ok, i will only be scanning anything on 1.25 meters range.", 0, false);
                    kinectRangeImageSet(2);
                }
                else if (recogText.Equals("Set range c"))
                {
                    cindy("Ok, i will only be scanning anything on 2 meters range.", 0, false);
                    kinectRangeImageSet(3);
                }
                else if (recogText.Equals("How are you"))
                {
                    temp = "I am well, How about you. ";
                    if (quietMode)
                    {
                        temp = temp + "You told me, to be quiet before and ";
                    }
                    if (vibrationStatus)
                    {
                        temp = temp + "you have set vibration on.";
                    }
                    else
                    {
                        temp = temp + "you have set vibration off.";
                    }

                    if (kinectRangeA.IsEnabled)
                    {
                        temp = temp + ". I am scanning any obstacle at 0.50 meter distance.";
                    }
                    else if (kinectRangeB.IsEnabled)
                    {
                        temp = temp + ". I am scanning any obstacle at 1.25 meter distance.";
                    }
                    else
                    {
                        temp = temp + ". I am scanning any obstacle at 1.75 meter distance.";
                    }
                    cindy(temp, -1, false);
                }
                else if (recogText.Equals("Can you sing"))
                {
                    cindy("You know that I can't sing. I'm not Adele but I can try, I heard that you found a girl and you married now ooowo oow ow.", -1, true);
                }
                else if (recogText.Equals("Be quiet"))
                {
                    if (quietMode)
                    {
                        quietMode = false;
                        cindy("Don't get angry, i didn't say anything.", 0, true);
                    }
                    else
                    {
                        cindy("Thank god, I'm going to be quiet. Bye.", 0, true);
                    }
                    quietMode = true;
                }
                else if (recogText.Equals("Dont be so quiet."))
                {
                    quietMode = false;
                    cindy("That's great, now i can talk to you.", 0, true);
                }
                else if (recogText.Equals("Apple"))
                {
                    cindy("Ha ha ha, i don't have it. Go to Tesco.", 0, false);
                }
                else if (recogText.Equals("Help me"))
                {
                    qm        = quietMode;
                    quietMode = false;
                    rangeScanAhead();
                    quietMode = qm;
                }
                else if (recogText.Equals("What's your name?"))
                {
                    cindy("I am cindy. Part of your OARC System, by " + SantoshGurung, 0, false);
                }
                // else if (recogText.Equals("Yes")) cindy("Great, don't worry. I am here for you.", 0);
                else /* Do nothing */ } {
                this.Title = "Voice: " + recogText;
        }
예제 #9
0
        // Method called from the recognizer when a recognition has occurred.
        // Only called for SpeechRecognition events, not SpeechRecognitionRejected.
        internal void OnRecognitionInternal(SpeechRecognizedEventArgs eventArgs)
        {
            Debug.Assert(eventArgs.Result.Grammar == this);

            SpeechRecognized?.Invoke(this, eventArgs);
        }
예제 #10
0
        void voz_Speech(object sender, System.Speech.Recognition.SpeechRecognizedEventArgs e)
        {
            foreach (RecognizedWordUnit word in e.Result.Words)
            {
                this.Dispatcher.Invoke(() =>
                {
                    if (word.Text.Equals("normal"))
                    {
                        Modo2.Content                = "Normal";
                        Soldado.Visibility           = Visibility.Hidden;
                        Mirilla.Visibility           = Visibility.Hidden;
                        Facial.Visibility            = Visibility.Hidden;
                        Reconocimiento.Visibility    = Visibility.Hidden;
                        Descripcion.Visibility       = Visibility.Hidden;
                        Radar.Visibility             = Visibility.Hidden;
                        Distancia.Visibility         = Visibility.Hidden;
                        Metros.Visibility            = Visibility.Hidden;
                        Probabilidad.Visibility      = Visibility.Hidden;
                        Porcentaje.Visibility        = Visibility.Hidden;
                        Mapa.Visibility              = Visibility.Hidden;
                        Flecha.Visibility            = Visibility.Hidden;
                        Vision.Visibility            = Visibility.Hidden;
                        Termometro.Visibility        = Visibility.Hidden;
                        Constantes.Visibility        = Visibility.Hidden;
                        TenienteRechazada.Visibility = Visibility.Hidden;
                        TenienteCogida.Visibility    = Visibility.Hidden;
                    }
                    else if (word.Text.Equals("infrarrojos"))
                    {
                        Modo2.Content             = "Infrarrojos";
                        Vision.Visibility         = Visibility.Visible;
                        Termometro.Visibility     = Visibility.Visible;
                        Radar.Visibility          = Visibility.Visible;
                        Distancia.Visibility      = Visibility.Visible;
                        Metros.Visibility         = Visibility.Visible;
                        Probabilidad.Visibility   = Visibility.Visible;
                        Porcentaje.Visibility     = Visibility.Visible;
                        Mapa.Visibility           = Visibility.Hidden;
                        Flecha.Visibility         = Visibility.Hidden;
                        Mirilla.Visibility        = Visibility.Visible;
                        Constantes.Visibility     = Visibility.Hidden;
                        Soldado.Visibility        = Visibility.Hidden;
                        Facial.Visibility         = Visibility.Hidden;
                        Reconocimiento.Visibility = Visibility.Hidden;
                        Descripcion.Visibility    = Visibility.Hidden;
                    }
                    else if (word.Text.Equals("defensa"))
                    {
                        Modo2.Content = "Defensa";


                        Soldado.Visibility      = Visibility.Visible;
                        Mirilla.Visibility      = Visibility.Visible;
                        Radar.Visibility        = Visibility.Visible;
                        Distancia.Visibility    = Visibility.Visible;
                        Metros.Visibility       = Visibility.Visible;
                        Probabilidad.Visibility = Visibility.Visible;
                        Porcentaje.Visibility   = Visibility.Visible;
                        Mapa.Visibility         = Visibility.Hidden;
                        Flecha.Visibility       = Visibility.Hidden;
                        Vision.Visibility       = Visibility.Hidden;
                        Termometro.Visibility   = Visibility.Hidden;
                        Constantes.Visibility   = Visibility.Hidden;
                    }
                    else if (word.Text.Equals("navegacion") || word.Text.Equals("navegación"))
                    {
                        Modo2.Content             = "Navegación y GPS";
                        Mapa.Visibility           = Visibility.Visible;
                        Flecha.Visibility         = Visibility.Visible;
                        Soldado.Visibility        = Visibility.Hidden;
                        Mirilla.Visibility        = Visibility.Hidden;
                        Facial.Visibility         = Visibility.Hidden;
                        Reconocimiento.Visibility = Visibility.Hidden;
                        Descripcion.Visibility    = Visibility.Hidden;
                        Radar.Visibility          = Visibility.Hidden;
                        Distancia.Visibility      = Visibility.Hidden;
                        Metros.Visibility         = Visibility.Hidden;
                        Probabilidad.Visibility   = Visibility.Hidden;
                        Porcentaje.Visibility     = Visibility.Hidden;
                        Vision.Visibility         = Visibility.Hidden;
                        Termometro.Visibility     = Visibility.Hidden;
                        Constantes.Visibility     = Visibility.Hidden;
                    }
                    else if (word.Text.Equals("reconocimiento"))
                    {
                        Modo2.Content             = "Reconocimiento Facial";
                        Soldado.Visibility        = Visibility.Visible;
                        Facial.Visibility         = Visibility.Visible;
                        Reconocimiento.Visibility = Visibility.Visible;
                        Descripcion.Visibility    = Visibility.Visible;
                        Mapa.Visibility           = Visibility.Hidden;
                        Flecha.Visibility         = Visibility.Hidden;
                        Vision.Visibility         = Visibility.Hidden;
                        Termometro.Visibility     = Visibility.Hidden;
                        Constantes.Visibility     = Visibility.Hidden;
                    }
                    else if (word.Text.Equals("vitales"))
                    {
                        Modo2.Content             = "Constantes Vitales";
                        Soldado.Visibility        = Visibility.Hidden;
                        Mirilla.Visibility        = Visibility.Hidden;
                        Facial.Visibility         = Visibility.Hidden;
                        Reconocimiento.Visibility = Visibility.Hidden;
                        Descripcion.Visibility    = Visibility.Hidden;
                        Radar.Visibility          = Visibility.Hidden;
                        Distancia.Visibility      = Visibility.Hidden;
                        Metros.Visibility         = Visibility.Hidden;
                        Probabilidad.Visibility   = Visibility.Hidden;
                        Porcentaje.Visibility     = Visibility.Hidden;
                        Mapa.Visibility           = Visibility.Hidden;
                        Flecha.Visibility         = Visibility.Hidden;
                        Constantes.Visibility     = Visibility.Visible;
                        Vision.Visibility         = Visibility.Hidden;
                        Termometro.Visibility     = Visibility.Hidden;
                    }
                    else if (word.Text.Equals("aceptar"))
                    {
                        TenienteCogida.Visibility = Visibility.Visible;
                        Teniente.Visibility       = Visibility.Hidden;
                        logout.Stop();
                    }
                    else if (word.Text.Equals("rechazar"))
                    {
                        TenienteRechazada.Visibility = Visibility.Visible;
                        Teniente.Visibility          = Visibility.Hidden;
                        logout.Stop();
                    }
                });
            }
        }
예제 #11
0
 internal void OnRecognitionInternal(SpeechRecognizedEventArgs eventArgs)
 {
     this.SpeechRecognized?.Invoke(this, eventArgs);
 }
예제 #12
0
        private void sre_SpeechRecognized(object sender, System.Speech.Recognition.SpeechRecognizedEventArgs e)
        {
            if (!bSpeaking)
            {
                ListViewItem lvi = lvReq.Items.Add(e.Result.Text);
                lvi.SubItems.Add((Math.Round(e.Result.Confidence, 2) * 100).ToString() + "%");
                lvi.SubItems.Add(DateTime.Now.ToLongTimeString());
                lvi.EnsureVisible();
                //foreach (SSR.RecognizedPhrase rp in e.Result.Alternates){
                string rpt = e.Result.Text;
                if (rpt.Equals("listen"))
                {
                    bListen = true;
                    speak("OK, talk to me.");
                }
                if (rpt.Equals("stop") && bListen)
                {
                    bListen    = false;
                    bSpell     = false;
                    bAddWordA  = false;
                    bAddWordQ  = false;
                    strNewword = "";
                    speak("My ears are shut.");
                }
                else if (bListen)
                {
                    if (rpt.Equals("add word") || rpt.Equals("add new word") || rpt.Equals("new word"))
                    {
                        bSpell     = true;
                        bAddWordQ  = false;
                        strNewword = "";
                        speak("Spell the word and say done, when done.");
                    }
                    else if (bSpell && rpt.Length == 1)
                    {
                        strNewword += rpt;
                        speak(strNewword);
                    }
                    else if (bSpell && !bAddWordQ && rpt.Equals("no"))
                    {
                        strNewword = strNewword.Length > 1 ? strNewword.Substring(0, strNewword.Length - 1) : "";
                        speak(strNewword);
                    }
                    else if (bSpell && rpt.Equals("done"))
                    {
                        bAddWordQ = true;
                        speak("Add word '" + strNewword + "'?");
                    }
                    else if (bSpell && bAddWordQ && rpt.Equals("yes"))
                    {
                        bSpell    = false;
                        bAddWordQ = false;
                        bAddWordA = true;
                        if (htWords.ContainsValue(strNewword.ToLower()))
                        {
                            speak("Word '" + strNewword + "' already exists.");
                        }
                        else
                        {
                            addWord(strNewword);
                            speak("Word '" + strNewword + "' added.");
                        }
                        strNewword = "";
                    }
                    else if (bSpell && bAddWordQ && rpt.Equals("no"))
                    {
                        bAddWordQ = false;
                        bAddWordA = true;
                        speak(strNewword);
                    }

                    /*else if (bSpell && rpt.Length != 1)
                     * {
                     *  speak("Please repeat!");
                     * }*/
                    else if (bSpell && rpt.Length > 1)
                    {
                        strNewword += strNewword.Length > 0?" " + rpt:rpt;
                        speak(strNewword);
                    }
                    else if (rpt.Equals("hello"))
                    {
                        speak("hello");
                    }
                    else if (rpt.Equals("thanks"))
                    {
                        speak("Don't mention it.");
                    }
                    else if (rpt.Equals("repeat"))
                    {
                        if (strSaidLast != "")
                        {
                            speak(strSaidLast);
                        }
                    }
                    else if (rpt.Equals("tell me the time"))
                    {
                        speak(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(), false);
                    }
                    else if (rpt.Equals("exit"))
                    {
                        Application.Exit();
                    }
                }
                //}
            }
        }
예제 #13
0
 private void SpeechRecognizedProxy(object sender, SpeechRecognizedEventArgs e)
 {
     this.SpeechRecognized?.Invoke(this, e);
 }