Exemple #1
0
    void TS()
    {
        if (Input.GetKeyDown(KeyCode.R)) //Control recording on R
        {
            if (!recording)
            {
                exampleStreaming.StartRec();
                recording = true;
                recordIcon.SetActive(true);
            }
            else
            {
                exampleStreaming.StopRec();
                recording = false;
                recordIcon.SetActive(false);
            }
        }
        if (playerContent.text != "") //Once we get the text from Speech to Text, Check its grammar and call Natural Language Understanding
        {
            if (Input.GetKeyDown(KeyCode.Return))
            {
                CheckGrammar(playerContent.text);
                NLU.AnalyzeText(playerContent.text);
                NLU.AnalyzeText(NPCContent.text);
                happybot = true;
            }
        }
        if (happybot) //If the Natural language understanding analysis is complete
        {
            if (NLU.sentenceValues.ContainsKey(playerContent.text) && NLU.sentenceValues.ContainsKey(NPCContent.text))
            {
                happybot = false;
                double?similar = CompareText(NLU.sentenceValues[playerContent.text], NLU.sentenceValues[NPCContent.text]);

                if (similar > 0.2) //Set similarity threshold to 0.2 and check if the sentences cross the threshold
                {
                    inputRelevanceText.text = "Content similarity Score: " + similar.Value.ToString("P2") + "\n" + "Is similar: " + "<color=green>" + "Yes" + "</color>";
                    if (correctSent)
                    {
                        CrossOutWord(NLU.sentenceValues[playerContent.text].lemma);
                    }
                }
                else
                {
                    inputRelevanceText.text = "Content similarity Score: " + similar.Value.ToString("P2") + "\n" + "Is similar: " + "<color=red>" + "No" + "</color>";
                }
            }
        }
        if (Input.GetKeyDown(KeyCode.Q)) //Get next question on Q
        {
            NPCContent.text         = GetDialogue(topic);
            playerContent.text      = "";
            GrammarMessage.text     = "";
            inputRelevanceText.text = "";
        }
    }
Exemple #2
0
    void TS()
    {
        //dB2.SetActive(true);
        //Debug.Log("TS called");
        if (Input.GetKeyDown(KeyCode.R))
        {
            if (!recording)
            {
                exampleStreaming.StartRec();
                recording = true;
                recordIcon.SetActive(true);
            }
            else
            {
                exampleStreaming.StopRec();
                recording = false;
                recordIcon.SetActive(false);
            }

            //Debug.Log("recording");
        }
    }
 void TS()
 {
     if (Input.GetKeyDown(KeyCode.R)) // Speech-to-Text Recording control
     {
         if (!recording)
         {
             exampleStreaming.StartRec();
             GrammarMessage.text = "";
             recording           = true;
             recordIcon.SetActive(true);
         }
         else
         {
             exampleStreaming.StopRec();
             recording = false;
             recordIcon.SetActive(false);
         }
     }
     //playerContent.text = "I do prefer artisanal lattes and hope it tastes good.";
     //NPCContent.text = "I highly recommend getting the coconut latte, it is actually made with real coconut cream!";
     if (playerContent.text != "")
     {
         if (Input.GetKeyDown(KeyCode.Return))
         {
             File.AppendAllText(userLogPath, NPCContent.text + "\n" + playerContent.text + "\n");
             CheckGrammar(playerContent.text);
             NLU.AnalyzeText(playerContent.text);
             NLU.AnalyzeText(NPCContent.text);
             happybot = true;
         }
     }
     if (happybot)
     {
         if (NLU.sentenceValues.ContainsKey(playerContent.text) && NLU.sentenceValues.ContainsKey(NPCContent.text))
         {
             happybot = false;
             double?similar = CompareText(NLU.sentenceValues[playerContent.text], NLU.sentenceValues[NPCContent.text]);
             File.AppendAllText(userLogPath, similar + "\n\n");
             double temp = similar.Value * 25.0;
             if (temp > 10)
             {
                 temp = 10f;
             }
             scoreRound    += temp;
             scoreText.text = "Total Score: " + scoreTotal.ToString("F0") + "\n" + "Round Score: " + scoreRound.ToString("F0");
             if (similar > 0.2)
             {
                 inputRelevanceText.text = "Content similarity Score: " + similar.Value.ToString("P2") + "\n" + "Is similar: " + "<color=green>" + "Yes" + "</color>";
                 if (correctSent)
                 {
                     CrossOutWord(NLU.sentenceValues[playerContent.text].lemma);
                 }
             }
             else
             {
                 inputRelevanceText.text = "Content similarity Score: " + similar.Value.ToString("P2") + "\n" + "Is similar: " + "<color=red>" + "No" + "</color>";
             }
         }
     }
     if (Input.GetKeyDown(KeyCode.Q))   // Get next question control
     {
         NPCContent.text         = GetDialogue(topic);
         playerContent.text      = "";
         GrammarMessage.text     = "";
         inputRelevanceText.text = "";
     }
 }