diff --git a/glados_control/scripts/coordinator.py b/glados_control/scripts/coordinator.py index 0fb7c8f..995aa7c 100755 --- a/glados_control/scripts/coordinator.py +++ b/glados_control/scripts/coordinator.py @@ -6,19 +6,28 @@ from openai_ros.srv import Completion, CompletionResponse import re import num2words +trigger_strings = ["hey glados", "hey glass", "hey glad us", "hey glades", "hey glads", "hey glad"] def replace_numbers(text): return re.sub(r"(\d+)", lambda x: num2words.num2words(int(x.group(0))), text) def callback(msg): global chat_service, pub - resp = chat_service(msg.data, 1.0) - text = resp.text.replace('\n', ' ') # Remove line-breaks - text = re.sub(r"\((.*?)\)", " ", text) # Remove anything in brackets - text = replace_numbers(text) # Make digits into text - text = re.sub(' +', ' ', text) # Unnecessary white space + for s in trigger_strings: + if s in msg.data.lower(): + text = msg.data.lower() + text = text.replace("hey glados", "") + text = text.replace("hey glass", "") - pub.publish(text) + resp = chat_service(text, 1.0) + + text = resp.text.replace('\n', ' ') # Remove line-breaks + text = re.sub(r"\((.*?)\)", " ", text) # Remove anything in brackets + text = replace_numbers(text) # Make digits into text + text = re.sub(' +', ' ', text) # Unnecessary white space + + pub.publish(text) + break def main(): global chat_service, pub diff --git a/glados_riva/scripts/glados_talk.py b/glados_riva/scripts/glados_talk.py index dd301ed..db4a84b 100644 --- a/glados_riva/scripts/glados_talk.py +++ b/glados_riva/scripts/glados_talk.py @@ -86,10 +86,10 @@ def main() -> None: while not rospy.is_shutdown(): if TTS != None: text_list = [TTS] - + if len(TTS) >= 400: text_list = TTS.split(".") - + for t in text_list: text = t.rstrip().lstrip() if len(text) < 1: