Author: Job van Dieten
Maintainer: Jordi Pages < jordi.pages@pal-robotics.com >, Job van Dieten < job.1994@gmail.com >
Source: https://github.com/pal-robotics/tiago_tutorials.git
Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags. |
PAL Text To Speech Interface (Python)
Description: PAL Robotics have created a Text to Speech interface. The following tutorial shows how to use the text to speech action, using the open source sound_play framework.Keywords: Python
Tutorial Level: INTERMEDIATE
Purpose
The purpose of this tutorial is to demonstrate the useful features offered by both the PAL Robotics Text-To-Speech Interface as some of the available actionlib features.
Pre-Requisites
This tutorial assumes that necessary repositories from Robots/TIAGo/Tutorials/Install have been installed, in particular the sound play package.
$ sudo apt-get install ros-indigo-sound-play
Execution
The execution of this code is a simple launch file. The package comes with two versions, depending on the users preference.
GUI
Those who wish to use the simple GUI format simply run the following command.
$ roslaunch tts tts.launch
Terminal
However if there are users who prefer to run everything through the terminal, add a type argument.
$ roslaunch tts tts.launch type:=terminal
Concepts & Code
The main driving forces behind this tutorial are the actionlib library and the PAL Robotics Text-To-Speech Interface action message.
actionlib
the actionlib_tutorials/Tutorials/SimpleActionClient and actionlib_tutorials/Tutorials/SimpleActionServer(ExecuteCallbackMethod) objects that actionlib provides are easy to work with. The server broadcasts a topic to which other nodes create a client subsequently publishing a goal.In the callback created for the server the parameters passed through the goal message are used to their desired effect. During the process the server publishes feedback to let the client node know where the action is in its process. After either completion or failure of the process, the server sends a result to the client node, indicating the final status of the desired action.
action message
The action message is split into three parts:
- goal
- result
- feedback
Goal
The goal gives the parameters for the action the target process has to execute.
I18nText text TtsText rawtext string speakerName float64 wait_before_speaking
- text
This variable contains an I18nText message, described in fuller detail later.
- rawtext
This variable contains an TtsText message, described in fuller detail later.
- speakerName
- Gives the option to choose between a variety of speakers for the same language, if the platform allows.
- wait_before_speaking
- Indicates how many seconds the platform has to wait before saying the text.
I18nText
string section string key string lang_id I18nArgument[] arguments
- section
- key
- lang_id
- This is the RFC 3006 code to select the language the text will be said in.
- arguments
TtsText
string text string lang_id
- text
- The string of user input that is to be said.
- lang_id
- This is the RFC 3006 code to select the language the text will be said in.
Result
This only gets published after the process is complete or fails, and terminates the action.
string text string msg
- text
- The complete string said by the platform.
- msg
- This string can be used to give any warning or error messages, thrown up by the platform, to the client.
Feedback
Feedback is continuously published while both threads (client and server) continue, allowing the client to process any other information it might need to pre-emptively cancel the goal, process data etc...
uint16 event_type time timestamp string text_said string next_word TtsMark marks
- event_type
- This shows what stage of the process is in. The integer value has 8 definitions