From d8853223d7e9aae41bd64daf6b70125a1662c86e Mon Sep 17 00:00:00 2001 From: Shingo Kitagawa Date: Sat, 25 Dec 2021 01:03:29 +0900 Subject: [PATCH 1/2] support non japanese languages --- .../node_scripts/dialogflow_client.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dialogflow_task_executive/node_scripts/dialogflow_client.py b/dialogflow_task_executive/node_scripts/dialogflow_client.py index 5f443346b..8e0e139b2 100755 --- a/dialogflow_task_executive/node_scripts/dialogflow_client.py +++ b/dialogflow_task_executive/node_scripts/dialogflow_client.py @@ -181,9 +181,15 @@ def speak_result(self, result): msg = SoundRequest( command=SoundRequest.PLAY_ONCE, sound=SoundRequest.SAY, - volume=1.0, - arg=result.fulfillment_text.encode('utf-8'), - arg2=self.language) + volume=1.0) + + # for japanese or utf-8 languages + if self.language == 'ja-JP': + msg.arg = result.fulfillment_text.encode('utf-8') + msg.arg2 = self.language + else: + msg.arg = result.fulfillment_text + self.sound_action.send_goal_and_wait( SoundRequestGoal(sound_request=msg), rospy.Duration(10.0)) From 8370548e183d4a47c51f687b0766cbc6c81c7729 Mon Sep 17 00:00:00 2001 From: Shingo Kitagawa Date: Sat, 25 Dec 2021 16:23:38 +0900 Subject: [PATCH 2/2] do not use utf-8 for result msg --- .../node_scripts/dialogflow_client.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dialogflow_task_executive/node_scripts/dialogflow_client.py b/dialogflow_task_executive/node_scripts/dialogflow_client.py index 8e0e139b2..ea94019c6 100755 --- a/dialogflow_task_executive/node_scripts/dialogflow_client.py +++ b/dialogflow_task_executive/node_scripts/dialogflow_client.py @@ -166,9 +166,14 @@ def publish_result(self, result): msg.header.stamp = rospy.Time.now() if result.action is not 'input.unknown': rospy.logwarn("Unknown action") - msg.query = result.query_text.encode("utf-8") msg.action = result.action - msg.response = result.fulfillment_text.encode("utf-8") + + if self.language == 'ja-JP': + msg.query = result.query_text.encode("utf-8") + msg.response = result.fulfillment_text.encode("utf-8") + else: + msg.query = result.query_text + msg.response = result.fulfillment_text msg.fulfilled = result.all_required_params_present msg.parameters = MessageToJson(result.parameters) msg.speech_score = result.speech_recognition_confidence