Difference between revisions of "Voice control (sphinx+festival)"

From robotica.unileon.es
Jump to: navigation, search
(Text speech)
Line 74: Line 74:
 
==Text speech==
 
==Text speech==
  
<!--
+
We have to use the class sound_play::SoundClient in order to use text speech in our program. The public functions of this class are shown below:
 
 
==Locución de texto==
 
 
 
Para poder realizar la locución de texto desde nuestro programa necesitamos hacer uso de la clase sound_play::SoundClient, en la cul se definen las siguientes funciones públicas:
 
  
 
<syntaxhighlight lang="cpp">
 
<syntaxhighlight lang="cpp">
Line 114: Line 110:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
La función que vamos a emplear es "say", que pronuncia una cadena de texto una sola vez, usando la voz por defecto "voice_kal_diphone". Para completar la reproducción de un archivo o cadena de texto es necesario hacer una pausa en la ejecución de nuestro código usando la función "sleep(segundos)".
+
We will use the function "say" that say once a string using the default synthesized voice "voice_kal_diphone". We have to use the function "sleep(seconds)" in order to pause the program execution to say the string.
 +
 
 +
==Control program MYRAbot==
 +
 
 +
 
 +
 
 +
<!--
  
 
==Programa de control MYRAbot==
 
==Programa de control MYRAbot==

Revision as of 21:37, 24 April 2014

< go back to main

Preliminary steps

We use CMU Pocket Sphinx for speech recognition developed on Carnegie Mellon University, and Festival Speech Synthesis System for text speech developed on University of Edinburgh.

Currently the ROS package pocketsphinx is available for groovy and hydro distributions. We can install it executing the next command in a terminal:

sudo apt-get install ros-"groovy or hydro"-pocketsphinx

We have to install the ubuntu package CMU Pocket Sphinx in previous ROS distributions. We will execute the next command in a terminal to install it:

sudo apt-get install gstreamer0.10-pocketsphinx

Moreover for previous ROS distributions, we have to download the ROS stack "rharmony" by University of Albany in order to integrate CMU Pocket Sphinx in ROS. We will place in the ROS workspace and we will execute the next commands in a terminal:

svn checkout http://albany-ros-pkg.googlecode.com/svn/trunk/rharmony
rosmake --rosdep-install pocketsphinx

Festival Speech Synthesis System is intigrated in the ROS package sound_play.

Speech recognition

First, we will execute the next command in a terminal within our workspace in order to create a package named "voz_fer" that will content the voice control programs:

roscreate-pkg voz_fer pocketsphinx sound_play std_msgs roscpp

We have to select the vocabulary that we use to control the robot. We use short sentences for the orders in order to reduce the recognition mistakes. We will create a file named "comandos_voz.txt" within the folder "config" of the created package with the content that is show below (each sentence must be in a new line):

start speech
stop speech
go forward
go back
turn left
turn right
speed up
slow down
rotate left
rotate right
stop
point beer
point cocacola
fold arm

We will upload and compile the created file "comandos_voz.txt" in the next link in order to generate the recognition vocabulary:

Sphinx knowledge base tool

We will download and rename (commandos_voz.*) the generated files within the folder "config" of the generated package. We will create a file named "comados_voz.launch" within the folder "launch" of the package in order to start CMU Pocket Sphinx with our vocabulary:

<launch>

  <node name="recognizer" pkg="pocketsphinx" type="recognizer.py" output="screen">
    <param name="lm" value="$(find voz_fer)/config/comandos.lm"/>
    <param name="dict" value="$(find voz_fer)/config/comandos.dic"/>
  </node>
  
</launch>

We will execute the next command in a terminal in order to start the speech recognition:

roslaunch voz_fer comandos_voz.launch

The results of the speech recognition are published in the topic "recognizer/output" (message type std_msgs/String). We will execute the next command in a terminal in order to see the results of the speech recognition:

rostopic echo recognizer/output

Text speech

We have to use the class sound_play::SoundClient in order to use text speech in our program. The public functions of this class are shown below:

Sound 	builtinSound (int id)
 	Create a builtin Sound.
void 	play (int sound)
 	Play a buildin sound.
void 	playWave (const std::string &s)
 	Plays a WAV or OGG file.
void 	repeat (const std::string &s)
 	Say a string repeatedly.
void 	say (const std::string &s, const std::string &voice="voice_kal_diphone")
 	Say a string.
void 	setQuiet (bool state)
 	Turns warning messages on or off.
 	SoundClient (ros::NodeHandle &nh, const std::string &topic)
 	Create a SoundClient that publishes on the given topic.
 	SoundClient ()
 	Create a SoundClient with the default topic.
void 	start (int sound)
 	Play a buildin sound repeatedly.
void 	startWave (const std::string &s)
 	Plays a WAV or OGG file repeatedly.
void 	stop (int sound)
 	Stop playing a built-in sound.
void 	stopAll ()
 	Stop all currently playing sounds.
void 	stopSaying (const std::string &s)
 	Stop saying a string.
void 	stopWave (const std::string &s)
 	Stop playing a WAV or OGG file.
Sound 	voiceSound (const std::string &s)
 	Create a voice Sound.
Sound 	waveSound (const std::string &s)

We will use the function "say" that say once a string using the default synthesized voice "voice_kal_diphone". We have to use the function "sleep(seconds)" in order to pause the program execution to say the string.

Control program MYRAbot

< go back to main