public void stopvideo() { function.gameObject.SetActive(true); TextToSpeechMark ttsm = gameObject.GetComponent <TextToSpeechMark>(); ttsm.Synthesize("What can I do for you?"); model.transform.localPosition = new Vector3(0, 0, 0); videodemo.gameObject.SetActive(false); videosound.Stop(); videoon = false; }
private void OnSuccess(object resp, Dictionary <string, object> customData) { SpeechToTextMark sttm = gameObject.GetComponent <SpeechToTextMark>(); sttm.Active = false; Log.Debug("TestConversation.OnMessage()", "Conversation: Message Response: {0}", customData["json"].ToString()); string[] splitanswer = customData["json"].ToString().Split(new string[] { "[", "]" }, StringSplitOptions.None); var newstring = splitanswer[5]; Debug.Log("new string " + newstring); // var index = newstring.Length; // newstring = newstring.Remove(0, 2); // newstring = newstring.Remove(index-2, 1); //intent string[] intents = customData["json"].ToString().Split(new string[] { "intent", "confidence" }, StringSplitOptions.None); var index1 = intents[2].Length; var intent = intents[2].Remove(0, 3); intent = intent.Remove(index1 - 6, 3); Debug.Log("intent!!!!" + intent); //greeting if (intent != "fal" /*&& !newstring.StartsWith("I didn't understand") && !newstring.StartsWith("Can you reword") */) { _questiontext.text = ""; _answer.text = newstring; if (intent == "打招呼") { function.gameObject.SetActive(true); company.gameObject.SetActive(false); } else if (intent == "公司信息") { // movecam.transform.localPosition = new Vector3(-0.45f, 1.87f, -5.98f); // model.transform.localEulerAngles = new Vector3(0, 220f, 0); company.gameObject.SetActive(true); // function.gameObject.SetActive(false); videodemo.gameObject.SetActive(false); } else if (intent == "视频") { videodemo.gameObject.SetActive(true); company.gameObject.SetActive(false); function.gameObject.SetActive(false); StartCoroutine(videodemoshow()); } else if (intent == "Cityname" || intent == "No" || intent == "Weather" || intent == "goodbyes") { // movecam.transform.localPosition = new Vector3(0f, 1.87f, -5.98f); // model.transform.localEulerAngles = new Vector3(0, 174f, 0); company.gameObject.SetActive(false); // function.gameObject.SetActive(false); videodemo.gameObject.SetActive(false); } else if (intent == "跳舞") { danceRob.StartCoroutine(danceRob.Losetime()); danceRob.StartCoroutine(danceRob.DanceTime()); company.gameObject.SetActive(false); // function.gameObject.SetActive(false); videodemo.gameObject.SetActive(false); } Debug.Log("intentttttttt!!!!!!!!!!!!!!!!" + intent); TextToSpeechMark ttsm = gameObject.GetComponent <TextToSpeechMark>(); // ttsm.Synthesize(_answer.text); Marktest.speaktuling(_answer.text); fsData fsdata = null; fsResult r = _serializer.TrySerialize(resp.GetType(), resp, out fsdata); if (!r.Succeeded) { throw new WatsonException(r.FormattedMessages); } // Convert fsdata to MessageResponse MessageResponse messageResponse = new MessageResponse(); //mark // string intentss = messageResponse.intents[0].intent; // Debug.Log("finaly!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + intentss); object obj = messageResponse; r = _serializer.TryDeserialize(fsdata, obj.GetType(), ref obj); if (!r.Succeeded) { throw new WatsonException(r.FormattedMessages); } object _tempContext = null; // Set context for next round of messaging (resp as Dictionary <string, object>).TryGetValue("context", out _tempContext); if (_tempContext != null) { _context = _tempContext as Dictionary <string, object>; } else { Log.Debug("TestConversation.OnMessage()", "Failed to get context"); } // Test(messageResponse != null); _waitingForResponse = false; // TextToSpeechMark ttsm = gameObject.GetComponent<TextToSpeechMark>(); // ttsm.Synthesize(""); // Convert resp to fsdata } else { startTuling(_questiontext.text); // company.gameObject.SetActive(false); /* request.rawInput = _questiontext.text; * _questiontext.text = ""; * request.StartedOn = DateTime.Now; * result = bot.Chat(request); * _answer.text = result.Output; * TextToSpeechMark ttsm = gameObject.GetComponent<TextToSpeechMark>(); * ttsm.Synthesize(_answer.text);*/ } // _questiontext.text = ""; }