From a41552f7c65c807cc80e14235570ef2abb942b52 Mon Sep 17 00:00:00 2001 From: Kasper Date: Sat, 27 Sep 2025 20:41:03 +0200 Subject: [PATCH] feat: basic implementation of CB2RI Nothing fancy yet. When we receive a message through ZeroMQ's PUB/SUB architecture, we tell the robot to say it out loud. --- main.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..f59b6d5 --- /dev/null +++ b/main.py @@ -0,0 +1,27 @@ +import qi +import zmq +import time + + +def say(session, message): + tts = session.service("ALTextToSpeech") + tts.say(message) + +if __name__ == "__main__": + app = qi.Application() + app.start() + session = app.session + + context = zmq.Context() + socket = context.socket(zmq.SUB) + socket.connect("tcp://localhost:5556") + socket.setsockopt_string(zmq.SUBSCRIBE, u"") # u because Python 2 shenanigans + + while True: + print("Listening for message") + message = socket.recv_string() + print("Received message: {}".format(message)) + + say(session, message) + + time.sleep(1)