From 6345748cf1b15c5178fce4f40d1212cff43a2ec4 Mon Sep 17 00:00:00 2001
From: Sergi Hernandez Juan <shernand@iri.upc.edu>
Date: Fri, 20 Oct 2017 09:56:30 +0000
Subject: [PATCH] Implemented the API functions of the TTS module.

---
 include/tiago_modules/tts_module.h |  6 +++---
 src/tts_module.cpp                 | 21 ++++++++++++---------
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/include/tiago_modules/tts_module.h b/include/tiago_modules/tts_module.h
index b7dddd1..78a4745 100644
--- a/include/tiago_modules/tts_module.h
+++ b/include/tiago_modules/tts_module.h
@@ -29,7 +29,8 @@ class CTTSModule : public CModule<tts_module::TTSModuleConfig>
     tts_module::TTSModuleConfig config;
 
     CModuleAction<pal_interaction_msgs::TtsAction> tts_action;
-    pal_interaction_msgs::TtsGoal goal;
+    pal_interaction_msgs::TtsGoal speech_goal;
+    std::string speaker;
 
     //Variables
     tts_module_state_t state;
@@ -44,9 +45,8 @@ class CTTSModule : public CModule<tts_module::TTSModuleConfig>
   public:
     //CTTSModule(const std::string &name);
     CTTSModule(const std::string &name,const std::string &name_space=std::string(""));
-    void set_language(std::string &language);
     void set_speaker(std::string &speaker);
-    void say(std::string &text,double delay=0.0);
+    void say(const std::string &text,const std::string &language=std::string("en_GB"),double delay=0.0);
     void stop(void);
     bool is_finished(void);
     tts_module_status_t get_status(void);
diff --git a/src/tts_module.cpp b/src/tts_module.cpp
index f3b050d..def7167 100644
--- a/src/tts_module.cpp
+++ b/src/tts_module.cpp
@@ -30,7 +30,7 @@ void CTTSModule::state_machine(void)
                           break;
 
     case TTS_MODULE_START: ROS_DEBUG("CTTSModule: Start");
-                           switch(this->tts_action.make_request(this->goal))
+                           switch(this->tts_action.make_request(this->speech_goal))
                            {
                              case ACT_SRV_SUCCESS: this->state=TTS_MODULE_WAIT;
                                                    ROS_DEBUG("CTTSModule : goal start successfull");
@@ -110,19 +110,22 @@ void CTTSModule::reconfigure_callback(tts_module::TTSModuleConfig &config, uint3
   this->unlock();
 }
 
-void CTTSModule::set_language(std::string &language)
-{
-
-}
-
 void CTTSModule::set_speaker(std::string &speaker)
 {
-
+  this->lock();
+  this->speaker=speaker;
+  this->unlock();
 }
 
-void CTTSModule::say(std::string &text,double delay)
+void CTTSModule::say(const std::string &text,const std::string &language,double delay)
 {
-
+  this->lock();
+  this->speech_goal.rawtext.text=text;
+  this->speech_goal.rawtext.lang_id=language;
+  this->speech_goal.wait_before_speaking=delay;
+  this->speech_goal.speakerName=this->speaker;
+  this->new_speech=true;
+  this->unlock();
 }
 
 void CTTSModule::stop(void)
-- 
GitLab