In ROS, there are some ROS packages that perform speech synthesis. Here, we will discuss one ROS package. This package uses Festival as the backend. The package name is sound_play
. It has nodes and launch scripts that enable speech synthesis. We need to perform the following steps for speech synthesis:
sound_play
package using the following command:$ sudo apt-get install ros-indigo-sound-play
$ catkin_create_pkg sample_tts rospy roscpp sound_play std_msgs
sound_play
python client code for sending text to sound play server node. This client will send the text that needs to be converted to speech to the sound_play
server node. The client will send the text to convert to speech in a Topic called /robotsound
. The sound play
node in the sound play package will subscribe to this Topic and convert the string from Topic to speech.sample_tts
package named scripts
and create the following code in the scripts
folder and name it test.py
. The code snippets of test.py
is given.rospy
and sound_play
modules. This script will act as a SoundClient
, which will connect to the sound_play
server and synthesize the speech:#!/usr/bin/env python import roslib; roslib.load_manifest('sample_tts') import rospy, os, sys from sound_play.msg import SoundRequest from sound_play.libsoundplay import SoundClient
soundplay_test
node and create an object of SoundClient
:if __name__ == '__main__': rospy.init_node('soundplay_test', anonymous = True) soundhandle = SoundClient() rospy.sleep(1) soundhandle.stopAll()
sound_play
as dependency.print 'Starting TTS' soundhandle.say('Hello world!') rospy.sleep(3) s = soundhandle.voiceSound("Hello World") s.play() rospy.sleep(3)
$ roslaunch sound_play soundplay_node.launch
$ rosrun sample_tts test.py
52.15.223.168