Exemplo n.º 1
0
 // Call to Python code which calls NAO API and enables Nico to move/speak
 private static void nicoMoveSpeak(string nicoresponse, int movementCode, string verbalManagerFile, string useraudio, string condition, string userid, DateTime time, int numturns)
 {
     try
     {
         string pythonexe  = "C:\\Python27\\python.exe";
         string pythonargs = verbalManagerFile + userid + " " + time + " " + useraudio + " " + nicoresponse + " " + condition + " " + numturns.ToString();
         ExternalMethodsCaller.PythonProcess(pythonexe, pythonargs);
     }
     catch (Exception error)
     {
         SQLLog.InsertLog(DateTime.Now, error.Message, error.StackTrace, "ResponseGeneration.nicoMoveSpeak", 1);
     }
 }
Exemplo n.º 2
0
        // This function takes in the speakers transcript and generates Nico's response
        // Output is:
        //              String - Transcript - path of the response file (what Nico said)
        //              Int - Movement - movement code (overwritten later by python movement code)
        //              Int - AnswerStep - did Nico answer this step
        private static Tuple <string, int, string> dialogueManager(string path, List <int> problemStep, int speakerSpoke, string transcript, DateTime time, bool checkIfAnswered, string condition)
        {
            // Return variables
            string answerStep       = "no answer";
            int    nicoMovementCode = 1;

            string pathTranscriptFile = "";
            string pathResponseFile   = "";
            string BOT = "nico";

            if (condition == "control")
            {
                BOT = "nico";
            }
            else
            {
                BOT = "nico";
            }

            try
            {
                // Save transcript to a file so pandora python api program can read it in; save response in a file as well
                pathResponseFile   = string.Format("{0}-{1:yyyy-MM-dd_hh-mm-ss-tt}", path + "data\\transcripts\\nlubold_nicoresponse", time) + ".txt";
                pathTranscriptFile = string.Format("{0}-{1:yyyy-MM-dd_hh-mm-ss-tt}", path + "data\\transcripts\\nlubold_transcript", time) + ".txt";
                StreamWriter transcriptFile = new StreamWriter(pathTranscriptFile);
                transcriptFile.Write(transcript);
                transcriptFile.Close();

                string pythonexe  = "C:\\Python27\\python.exe";
                string pythonargs = "C:\\Python27\\NaoNRIPrograms\\VerbalManager\\chatPandoraBot.py " + pathTranscriptFile + " " + pathResponseFile + " " + BOT;

                ExternalMethodsCaller.PythonProcess(pythonexe, pythonargs);

                string nicoResponseText = readResponse(pathResponseFile);
                string lastAnswer       = SQLNicoState.ReadNicoState_Answer();
                if (checkIfAnswered && (nicoResponseText.Contains("put the answer")))
                {
                    answerStep = "answering";
                }
            }
            catch (Exception error)
            {
                // ** WRITE OUT TO DB
                SQLLog.InsertLog(DateTime.Now, error.Message, error.StackTrace, "ResponseGeneration.generateNicoResponse", 1);
            }

            Tuple <string, int, string> result = new Tuple <string, int, string>(pathResponseFile, nicoMovementCode, answerStep);

            return(result);
        }
Exemplo n.º 3
0
        // Call to Python code for agent/robot to move or speak
        private static void moveSpeak(string path, string pathResponseFile, int movementCode, string verbalManagerFile, string useraudio, string condition, string userid, DateTime time, int numturns, string robotIP, string enttype, bool agent)
        {
            try
            {
                if (agent)
                {
                    string agentAudioPath = "../data/agentAudio/" + generateSpeech(userid, condition, pathResponseFile, path);
                    if (enttype == "None")
                    {
                        ProcessThreadCollection currentThreads = Process.GetCurrentProcess().Threads;
                        Thread.Sleep(2000);
                    }
                    else
                    {
                        string pythonexe  = Globals.pythonDirectory() + "python.exe";
                        string formatdate = string.Format("{0:yyyy-MM-dd_hh-mm-ss-tt}", time);
                        if (useraudio == "")
                        {
                            useraudio = Globals.pythonDirectory() + "NaoNRIPrograms\\NicoAudio\\response.wav";
                        }
                        string agentAudio = agentAudioPath;
                        string gender     = SQLConditionGenderInfo.GetGender(userid);
                        string pythonargs = verbalManagerFile + userid + " " + formatdate + " " + useraudio + " " + agentAudio + " " + condition + " " + numturns.ToString() + " " + enttype + " " + gender;
                        ExternalMethodsCaller.PythonProcess(pythonexe, pythonargs);

                        Thread.Sleep(1000);
                    }

                    MyHub.Start(userid, agentAudioPath);
                }
                else
                {
                    string pythonexe  = Globals.pythonDirectory() + "python.exe";
                    string formatdate = string.Format("{0:yyyy-MM-dd_hh-mm-ss-tt}", time);
                    if (useraudio == "")
                    {
                        useraudio = Globals.pythonDirectory() + "NaoNRIPrograms\\NicoAudio\\response.wav";
                    }
                    string pythonargs = verbalManagerFile + userid + " " + formatdate + " " + useraudio + " " + pathResponseFile + " " + condition + " " + numturns.ToString() + " " + robotIP + " " + enttype;
                    ExternalMethodsCaller.PythonProcess(pythonexe, pythonargs);
                }
            }
            catch (Exception error)
            {
                SQLLog.InsertLog(DateTime.Now, error.Message, error.StackTrace, "ResponseGeneration.moveSpeak", 1);
            }
        }
Exemplo n.º 4
0
 // Call to Python code which calls NAO API and enables Nico to move/speak
 private static void nicoMoveSpeak(string nicoresponse, int movementCode, string verbalManagerFile, string useraudio, string condition, string userid, DateTime time, int numturns, string robotIP)
 {
     try
     {
         string pythonexe  = "C:\\Python27\\python.exe";
         string formatdate = string.Format("{0:yyyy-MM-dd_hh-mm-ss-tt}", time);
         if (useraudio == "")
         {
             useraudio = @"C:\Python27\NaoNRIPrograms\NicoAudio\response.wav";
         }
         string pythonargs = verbalManagerFile + userid + " " + formatdate + " " + useraudio + " " + nicoresponse + " " + condition + " " + numturns.ToString() + " " + robotIP;
         ExternalMethodsCaller.PythonProcess(pythonexe, pythonargs);
     }
     catch (Exception error)
     {
         SQLLog.InsertLog(DateTime.Now, error.Message, error.StackTrace, "ResponseGeneration.nicoMoveSpeak", 1);
     }
 }
Exemplo n.º 5
0
        // This function takes in the speakers transcript and generates Nico's response
        // Output is:
        //              String - Transcript - path of the response file (what Nico said)
        //              Int - Movement - movement code (overwritten later by python movement code)
        //              Int - AnswerStep - did Nico answer this step
        private static Tuple <string, int, string> dialogueManager(string userid, string path, List <int> problemStep, int speakerSpoke, string transcript, DateTime time, bool checkIfAnswered, string condition)
        {
            // Return variables
            string answerStep       = "no answer";
            int    nicoMovementCode = 1;

            string pathTranscriptFile = "";
            string pathResponseFile   = "";
            string BOT          = "";
            string problemset   = (SQLConditionGenderInfo.GetProblemSet(userid)).ToLower();
            string responseText = "";

            /*  CREATE BOT NAME
             *
             * Pandorabots available:
             *      asocialemma        Corresponds to Emma Single Session Problem Set and includes social dialogue
             *      anonsocialemma     Corresponds to Emma Single Session Problem Set
             *      emmab          Corresponds to Emma Multi Session 1
             *      emmac               Corresponds to Emma Multi Session 1
             *      emmad               Corresponds to Emma Multi Session 1
             *      emmae               Corresponds to Emma Multi Session 1
             *      emmaf               Corresponds to Emma Multi Session 1
             *      gsocialnico        Corresponds to Nico Single Session Problem Set and includes social dialogue
             *      gnonsocialnico     Corresponds to Nico Single Session Problem Set, no social dialogue
             * */

            if (problemset == "a")
            {
                if (condition.Contains("nonsocial"))
                {
                    BOT = problemset + "nonsocialemma";
                }
                else
                {
                    BOT = problemset + "socialemma";
                }
            }
            else if (problemset == "g")
            {
                if (condition.Contains("nonsocial"))
                {
                    BOT = problemset + "nonsocialnico";
                }
                else
                {
                    BOT = problemset + "socialnico";
                }
            }
            else
            {
                BOT = "emma" + problemset;
            }

            try
            {
                // Save transcript to a file so pandora python api program can read it in; save response in a file as well
                pathResponseFile   = string.Format("{0}-{1:yyyy-MM-dd_hh-mm-ss-tt}", path + "data\\transcripts\\" + userid + "_nicoresponse", time) + ".txt";
                pathTranscriptFile = string.Format("{0}-{1:yyyy-MM-dd_hh-mm-ss-tt}", path + "data\\transcripts\\" + userid + "_transcript", time) + ".txt";
                StreamWriter transcriptFile = new StreamWriter(pathTranscriptFile);
                transcriptFile.Write(transcript);
                transcriptFile.Close();

                string pythonexe  = Globals.pythonDirectory() + "python.exe";
                string pythonargs = Globals.pythonDirectory() + "NaoNRIPrograms\\VerbalManager\\chatPandoraBot.py " + pathTranscriptFile + " " + pathResponseFile + " " + BOT + " " + userid;

                ExternalMethodsCaller.PythonProcess(pythonexe, pythonargs);

                responseText = readResponse(pathResponseFile);
                string lastAnswer = SQLNicoState.ReadNicoState_Answer(userid);
                if (checkIfAnswered && (responseText.Contains("put the answer")))
                {
                    answerStep = "answering";
                }
            }
            catch (Exception error)
            {
                // ** WRITE OUT TO DB
                SQLLog.InsertLog(DateTime.Now, error.Message, error.StackTrace, "ResponseGeneration.generateNicoResponse", 1);
            }

            Tuple <string, int, string> result = new Tuple <string, int, string>(responseText, nicoMovementCode, answerStep);

            return(result);
        }