ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Text to speech in a python node

asked 2011-08-04 13:27:05 -0500

ringo42 gravatar image

updated 2014-01-28 17:10:09 -0500

ngrennan gravatar image

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
5

answered 2011-08-04 14:46:42 -0500

Pi Robot gravatar image

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

or

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

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

from sound_play.libsoundplay import SoundClient

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

--patrick

edit flag offensive delete link more

Comments

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).

dinosaur gravatar image dinosaur  ( 2015-09-21 23:02:32 -0500 )edit

Question Tools

Stats

Asked: 2011-08-04 13:27:05 -0500

Seen: 1,477 times

Last updated: Aug 04 '11