Rosanswers logo

I've done the soundplay tutorial and can do text-to-speech from the command line, but can someone explain how to do it from inside a python program?

Originally posted by ringo42 on ROS Answers with karma: 55 on 2011-08-04

Post score: 1


1 Answer 1


Rosanswers logo

Hi Ringo,

The following works for me in Diamondback.

First add a dependency on sound_play to your package manifest.xml file:

<depend package="sound_play"/>

and re-run rosmake in your package directory.

Then launch the soundplay node from the command line or your launch file:

$ rosrun sound_play soundplay_node.py


  <node name="soundplay_node" pkg="sound_play" type="soundplay_node.py"/>

Finally, add the following Python snippets to your main speech script.

from sound_play.libsoundplay import SoundClient

self.soundhandle = SoundClient()
self.soundhandle.say('Take me to your leader.')


Originally posted by Pi Robot with karma: 4046 on 2011-08-04

This answer was ACCEPTED on the original site

Post score: 5

Original comments

Comment by dinosaur on 2015-09-21:
I did this in hydro on a PR2. It worked without adding the dependency. Also, our PR2 automatically runs a soundplay node. If a second one is accidentally started, speech sounds choppy until the whole system is restarted (even restarting all ros processes doesn't fix it).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.