Files
pepperplus-ri/main.py
Kasper a41552f7c6 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.
2025-09-27 20:41:03 +02:00

28 lines
618 B
Python

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)