Ejemplo n.º 1
0
        private static void SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            const double ConfidenceThreshold = 0.70;

            if (e.Result.Confidence >= ConfidenceThreshold && !LastAction.Equals(e.Result.Semantics.Value.ToString()))
            {
                if (GlobalManager.STANDBY == false)
                {
                    Console.WriteLine("Phrase reconnue: " + e.Result.Text);
                    PlugResponse response = GlobalManager.FireAction(e.Result.Semantics.Value.ToString(), e.Result.Text);
                    if (!e.Result.Semantics.Value.ToString().Equals("EXIT"))
                    {
                        speaker.Speak(response.Response);
                        System.Threading.Thread.Sleep(1000);
                    }
                }
                else
                {
                    switch (e.Result.Semantics.Value.ToString())
                    {
                    case "ON":
                        speaker.Speak("Réveil en cours");
                        speaker.Speak("Je suis prêt à vous obéir");
                        GlobalManager.STANDBY = false;
                        break;
                    }
                }
                //System.Threading.Thread.Sleep(1000);
            }
            else if (LastAction.Equals(e.Result.Semantics.Value.ToString()))
            {
                speaker.Speak("Je viens de te répondre...");
            }
        }
Ejemplo n.º 2
0
 public ImapProvider(string Host, string login, string pass, Int32 Port)
 {
     HOST     = Host;
     LOGIN    = login;
     PWD      = pass;
     PORT     = Port;
     RESPONSE = new PlugResponse();
 }
Ejemplo n.º 3
0
        private static PlugResponse Humeur(PlugCall call)
        {
            PlugResponse response = new PlugResponse();

            response.WaitForChainedAction = false;
            response.Response             = "Je vais bien, merci";
            return(response);
        }
Ejemplo n.º 4
0
        private static PlugResponse StandBy(PlugCall call)
        {
            GlobalManager.STANDBY = true;
            PlugResponse response = new PlugResponse();

            response.WaitForChainedAction = false;
            response.Response             = "Mode espion activé";
            return(response);
        }
Ejemplo n.º 5
0
        public static PlugResponse FireAction(string ActionName, string sentence)
        {
            PlugResponse response = new PlugResponse();
            PlugCall     call     = new PlugCall();

            call.ACTION = ActionName;
            call.Text   = sentence;

            SENTENCES tmp = CONTEXT.SENTENCESLIST.Where(t => t.CMD.CMD.Equals(ActionName)).Where(t => t.SENTENCE.Equals(sentence)).Single();

            // Todo: recherche une correspondance dans la BDD
            if (tmp == null)
            {
                return(new PlugResponse());
            }

            else
            {
                // Chargement de la DLL concernée
                SENTENCES cmd = GlobalManager.CONTEXT.SENTENCESLIST.Where(t => t.CMD.CMD.Equals(ActionName) && t.SENTENCE.Equals(sentence)).Single();
                if (cmd.CMD.MODULE.NAME.Equals("SYSTEM"))
                {
                    response     = SYSMODULE.DoAction(call);
                    LastResponse = response;
                    return(response);
                }
                else
                {
                    /* TEST */
                    // Chargement de la DLL
                    string          DLLPATH    = cmd.CMD.MODULE.DLL;
                    List <Assembly> assemblies = new List <Assembly>();
                    Assembly        DLL        = Assembly.LoadFrom(@"C:\Users\adasilva\Documents\Visual Studio 2015\Projects\MATHIAS\Mathias\bin\Debug\plugins\EmailPlug.dll");

                    // Récupération de l'objet à utiliser
                    var typeFromPlug = DLL.GetType(cmd.CMD.FULLTYPEOBJECT);
                    var plug         = Activator.CreateInstance(typeFromPlug, new object[] { "imap.gmail.com", "login", "password", 993 });

                    // Récupération de la méthode
                    var method = typeFromPlug.GetMethod("DoAction");

                    //Execution de la méthode et retour du cast
                    return((PlugResponse)method.Invoke(plug, new object[] { call }));
                }

                response = new PlugResponse();
                // LOAD DLL
            }

            // Création de l'objet PlugCall
            // Lancement de la méthode concernée
            // Si non
            // Indiquer aucune commande correspondante.

            return(null);
        }
Ejemplo n.º 6
0
        private static PlugResponse Hello(PlugCall call)
        {
            PlugResponse response = new PlugResponse();

            response.WaitForChainedAction = true;
            response.ChainedQuestion      = "Comment ça va ?";
            response.Response             = "Bonjour !";
            response.NextChainedAction    = "HUMEUR";
            return(response);
        }
Ejemplo n.º 7
0
        private static PlugResponse ContextChange(PlugCall call)
        {
            PlugResponse response = new PlugResponse();

            response.Response             = "Quel contexte voulez vous charger ?";
            response.WaitForChainedAction = true;
            response.NextChainedAction    = "LOAD CONTEXT";
            GlobalManager.LastResponse    = response;
            return(response);
        }