Skip to content

Commit

Permalink
Added startup sentence option.
Browse files Browse the repository at this point in the history
  • Loading branch information
BennyR committed May 9, 2014
1 parent 4db7c12 commit 2a47d19
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions cerevoice_tts/launch/tts.launch
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0"?>
<launch>
<param name="cerevoice_tts_node/startup_sentence" type="string" value="Text zu Sprache bereit." />
<rosparam param="voices" ns="cerevoice_tts_node" subst_value="true">
- path: $(env HOME)/cerevoice_sdk/voices/cerevoice_alex_3.0.6_22k.voice
license: $(env HOME)/cerevoice_sdk/voices/license.lic
Expand Down
36 changes: 36 additions & 0 deletions cerevoice_tts/src/cerevoice_tts_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@

#include "ros/ros.h"

#include <actionlib/client/simple_action_client.h>

#include "cerevoice_tts/CerevoiceTts.h"
#include "cerevoice_tts_msgs/TtsAction.h"

int main(int argc, char **argv)
{
Expand All @@ -48,6 +51,39 @@ int main(int argc, char **argv)
if(!initialized)
return EXIT_FAILURE;

ros::spinOnce();

ros::NodeHandle private_node_handle("~");
std::string startup_sentence;
private_node_handle.param("startup_sentence", startup_sentence, std::string(""));

if(!startup_sentence.empty())
{
ROS_INFO("Will now say the startup sentence '%s'", startup_sentence.c_str());
ROS_INFO("Will wait for server");

// Output this startup sentence
actionlib::SimpleActionClient<cerevoice_tts_msgs::TtsAction> action_client("TTS", true);
while(!action_client.isServerConnected())
{
ros::spinOnce(); // this looped spinning is required because we call an action from within the same node
}

ROS_INFO("Server ready");

cerevoice_tts_msgs::TtsGoal goal;
goal.text = startup_sentence;

action_client.sendGoal(goal);
while(!action_client.waitForResult(ros::Duration(0.0001)))
{
ros::spinOnce();
}

if(action_client.getState() != actionlib::SimpleClientGoalState::SUCCEEDED)
ROS_ERROR("Synthesizing the startup sentence failed!");
}

ros::spin();

return EXIT_SUCCESS;
Expand Down

0 comments on commit 2a47d19

Please sign in to comment.