charactercapital
charactercapital

Reputation: 15

ROS: How to use sound_play to speak messages published to a topic?

I am a beginner with ROS and am trying to use ROS sound_play package to speak out loud my messages (which is in string format) that I have published to a particular topic.

So far, I am able to print out the messages onto my ROS terminal using the command $rostopic echo / , but I want my machine to concurrently SPEAK these exact messages that are printed out on my terminal.

I have also tried the command $rosrun sound_play say.py "" for my machine to speak the specific string text I input. My question is, how can I integrate sound_play to actually speak out the messages published to my topic that I have printed onto my terminal using the echo command?

Any help would be appreciated, thanks!

Upvotes: 0

Views: 317

Answers (1)

hardesh
hardesh

Reputation: 31

I think instead of using this package, I would recommend using a Python text to speech library like https://pypi.org/project/pyttsx3/

Instead of publishing the string, you can simply pass the string to the API of this library to play the sound.

Hope this helps.

Upvotes: 0

Related Questions