mirror of
https://github.com/davesarmoury/GLaDOS.git
synced 2025-11-04 14:49:45 +08:00
Fixed up talking and coordination
This commit is contained in:
parent
8f6df2a411
commit
139ae55590
@ -6,12 +6,20 @@ 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)
|
||||
|
||||
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", "")
|
||||
|
||||
resp = chat_service(text, 1.0)
|
||||
|
||||
text = resp.text.replace('\n', ' ') # Remove line-breaks
|
||||
text = re.sub(r"\((.*?)\)", " ", text) # Remove anything in brackets
|
||||
@ -19,6 +27,7 @@ def callback(msg):
|
||||
text = re.sub(' +', ' ', text) # Unnecessary white space
|
||||
|
||||
pub.publish(text)
|
||||
break
|
||||
|
||||
def main():
|
||||
global chat_service, pub
|
||||
|
||||
Loading…
Reference in New Issue
Block a user