コード例 #1
0
    public IEnumerator AsyncDialogflowCall(string textRequest)
    {
        Task <AIResponse> nluCAll = Task.Run <AIResponse>(() => apiAiUnity.TextRequest(textRequest));

        //Warte bis Anfrage beendet wurde
        while (!nluCAll.IsCompleted)
        {
            yield return(null);
        }
        AIResponse response = nluCAll.Result;

        if (response != null)
        {
            //Debug.Log("Resolved query: " + response.Result.ResolvedQuery);
            //Debug.Log(response.Result.Metadata.IntentName);
            //var outText = fastJSON.JSON.ToJSON(response);
            var outText = NewJSon::Newtonsoft.Json.JsonConvert.SerializeObject(response, jsonSettings);
            Debug.Log("Result: " + outText);
        }
        else
        {
            Debug.LogError("Response is null");
        }

        Debug.Log("Trigger NLUAnswerDetected Event");
        EventManager.TriggerEvent(EventManager.nluAnswerDetectedEvent, new EventMessageObject(EventManager.nluAnswerDetectedEvent, response));
    }
コード例 #2
0
ファイル: ApiAiModule.cs プロジェクト: ShehryarX/visualflow
    public void SendText(string text)
    {
        ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) {
            return(true);
        };

        try {
            var response = apiAiUnity.TextRequest(text);
            if (response != null)
            {
                string outText     = JsonConvert.SerializeObject(response);
                string targetBegin = "\"speech\":\"";
                string targetEnd   = "\"},\"source\"";
                String result      = getStringInBetween(outText, targetBegin, targetEnd);

                Debug.Log("Result: " + result);
                WindowsVoice.speak(result);
            }
            else
            {
                Debug.LogError("Response is null");
            }
        }
        catch (Exception ex) {
            Debug.LogException(ex);
        }
    }
コード例 #3
0
    public void SendText()
    {
        var text = inputTextField.text;

        Debug.Log(text);

        AIResponse response = apiAiUnity.TextRequest(text);

        if (response != null)
        {
            Debug.Log("Resolved query: " + response.Result.ResolvedQuery);
            var outText = JsonConvert.SerializeObject(response, jsonSettings);

            var pattern = @"speech"":""(.+?)""";
            var match   = Regex.Match(outText, pattern);

            Debug.Log("Result: " + match.Groups[1]);

            answerTextField.text = match.Groups[1].ToString();

            tryToDoAction(match.Groups[1].ToString());
        }
        else
        {
            Debug.LogError("Response is null");
        }
    }
コード例 #4
0
    public void SendText()
    {
        //var text = SelectionSlider.speak;
        var text = lines[compteur];

        compteur++;
        //Debug.Log(text);

        AIResponse response = apiAiUnity.TextRequest(text);

        if (response != null)
        {
            Debug.Log(response.Result.Fulfillment.Speech);
            FindObjectOfType <TextToSpeech>().Speak(reponses[compteura]);
            compteura++;
            text = response.Result.Fulfillment.Speech;
            //FindObjectOfType<TextToSpeech>().Speak(text);

            /*if(SelectionSlider.speak.ToLower().Contains("presentation"))
             * {
             *  StartCoroutine(FinalScore(text));
             * }*/
        }
        else
        {
            Debug.LogError("Response is null");
        }
    }
コード例 #5
0
    public void SendText(String text)
    {
        Debug.Log(text);

        AIResponse response = apiAiUnity.TextRequest(text);

        if (response != null)
        {
            Debug.Log("Resolved query: " + response.Result.ResolvedQuery);
            var outText = JsonConvert.SerializeObject(response, jsonSettings);

            Debug.Log("Result: " + outText);
            String[] new1 = outText.Split(':');
            //   Debug.Log(new1.Length);
            //  for (int i=0;i<new1.Length;i++)
            //  {
            Debug.Log(new1[14]);
            String[] res  = new1[14].Split('}');
            String   res1 = res[0];
            res1 = res1.Substring(1, res1.Length - 2);
            //  }
            gm.SetActive(true);
            answerTextField.text = res1;
            ttss();
            StartCoroutine(PauseRoutine());
        }
        else
        {
            Debug.LogError("Response is null");
        }
    }
コード例 #6
0
ファイル: BotController.cs プロジェクト: UnityULL/Practica6
    public void SendText(string question)
    {
        AIResponse response = apiAiUnity.TextRequest(question);

        if (response != null)
        {
            int    val  = 0;
            string type = response.Result.Metadata.IntentName;
            string text = response.Result.Fulfillment.Speech;
            if (type == "Bienvenido")
            {
                val = 0;
            }
            else if (type == "explicacion")
            {
                val = 1;
            }
            else if (type == "lugar")
            {
                val = 2;
            }
            else if (type == "nombre")
            {
                val = 3;
            }
            GameController.HandleResponse(val);
            Debug.Log(text);
        }
        else
        {
            Debug.LogError("Response is null");
            print("-> ERROR");
        }
    }
コード例 #7
0
    public void SendText(string text_) // Sirve para enviar cadenas de texto al bot de DialogFlow
    {
        AIResponse response = apiAiUnity.TextRequest(text_);

        if (response != null)
        {
            Debug.Log("Resolved query: " + response.Result.ResolvedQuery);
        }
        else
        {
            Debug.LogError("Response is null");
        }
    }
コード例 #8
0
    public string SendText(string textToSend)
    {
        AIResponse response = apiAiUnity.TextRequest(textToSend);

        if (response != null)
        {
            return(response.Result.Fulfillment.Speech);
        }
        else
        {
            Debug.LogError("Response is null");
            return(null);
        }
    }
コード例 #9
0
    public void SendText(string text)
    {
        Debug.Log(text);

        AIResponse response = apiAiUnity.TextRequest(text);

        if (response != null)
        {
            Debug.Log("Resolved query: " + response.Result.ResolvedQuery);
            var outText = JsonConvert.SerializeObject(response, jsonSettings);

            Debug.Log("Result: " + outText);
        }
        else
        {
            Debug.LogError("Response is null");
        }
    }
コード例 #10
0
    public void SendText(String asking)
    {
        var text = asking;

        Debug.Log(text);

        AIResponse response = apiAiUnity.TextRequest(text);

        if (response != null)
        {
            apiAiText.text = text + ": " + response.Result.Fulfillment.Speech;

            Debug.Log("Result: " + response);
        }
        else
        {
            Debug.LogError("Response is null");
        }
    }
コード例 #11
0
ファイル: AppManagerScript.cs プロジェクト: bigdot-app/BigDOT
    public void SendTextToApiAi(string text)
    {
        ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) {
            return(true);
        };

        try {
            var response = apiaiClient.TextRequest(text);
            if (response != null)
            {
                ProcessOutput(response);
            }
            else
            {
                utilsPlugin.ShowToastMessage("Response is null");
            }
        } catch (Exception ex) {
            utilsPlugin.ShowAlertPopup("API.AI Error", "Error while processing API.AI response: " + ex);
        }
    }
コード例 #12
0
ファイル: BotEngine.cs プロジェクト: ShehryarX/visualflow
    public void SendText(string text)
    {
        ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) {
            return(true);
        };

        try {
            var response = apiAiUnity.TextRequest(text);
            if (response != null)
            {
                ProcessOutput(response);
            }
            else
            {
                Debug.LogError("Response is null");
            }
        }
        catch (Exception ex) {
            Debug.LogException(ex);
        }
    }
コード例 #13
0
ファイル: Chatbot.cs プロジェクト: elmoconh/LearnAI_V1.0
    public void SendText()
    {
        var text = inputTextField.text;

        Debug.Log(text);

        AIResponse response = apiAiUnity.TextRequest(text);

        if (response != null)
        {
            Debug.Log("Resolved query: " + response.Result.ResolvedQuery);
            var outText = JsonConvert.SerializeObject(response, jsonSettings);

            Debug.Log("Result: " + outText);

            answerTextField.text   = response.Result.ResolvedQuery;
            responseTextField.text = response.Result.Fulfillment.Speech;
        }
        else
        {
            Debug.LogError("Response is null");
        }
    }
コード例 #14
0
    public String SendText(String question)
    {
        AIResponse response = apiAiUnity.TextRequest(question);

        if (response != null)
        {
            Debug.Log("Resolved query: " + response.Result.ResolvedQuery);
            var outText = JsonConvert.SerializeObject(response, jsonSettings);

            var pattern = @"speech"":""(.+?)""";
            var match   = Regex.Match(outText, pattern);

            Debug.Log("Result: " + match.Groups[1]);


            return(match.Groups[1].ToString());
            //tryToDoAction(match.Groups[1].ToString());
        }
        else
        {
            return("Response is null");
        }
    }