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.
This commit is contained in:
27
main.py
Normal file
27
main.py
Normal file
@@ -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)
|
||||
Reference in New Issue
Block a user