1 #include <yarp/os/all.h> 13 if(!yarp::os::Network::isConnected(
"/iSpeak/emotions:o",
"/icub/face/emotions/in")) {
14 yarp::os::Network::connect(
"/iSpeak/emotions:o",
"/icub/face/emotions/in");
16 bool connected =
true;
17 if(!yarp::os::Network::isConnected(
tts.getName(),
"/iSpeak")) {
18 connected &= yarp::os::Network::connect(
tts.getName(),
"/iSpeak");
20 if(!yarp::os::Network::isConnected(
portRPC.getName(),
"/iSpeak/rpc")) {
21 connected &= yarp::os::Network::connect(
portRPC.getName(),
"/iSpeak/rpc");
29 yWarning() <<
"[SubSystem_Speech] Text is empty, not going to say anything";
33 std::string tmpText =
text;
35 yarp::os::Bottle txt; txt.addString(tmpText.c_str());
41 yarp::os::Bottle cmd, reply;
42 cmd.addVocab(yarp::os::createVocab(
's',
't',
'a',
't'));
43 std::string status =
"speaking";
44 bool speechStarted =
false;
46 while (shouldWait && (!speechStarted || status ==
"speaking"))
49 status = reply.get(0).asString();
50 if (!speechStarted && status !=
"quiet")
54 yarp::os::Time::delay(0.2);
60 yarp::os::Bottle param;
61 param.addString(
"set");
62 param.addString(
"opt");
63 param.addString(custom.c_str());
66 yWarning() <<
"SetOptions called with none for iSpeak";
71 yarp::os::Bottle cmd, reply;
72 cmd.addVocab(yarp::os::createVocab(
's',
't',
'a',
't'));
74 return (reply.get(0).asString() !=
"quiet");
virtual void TTS(const std::string &text, bool shouldWait=true)
Produce text to speech output.
yarp::os::RpcClient portRPC
void replace_all(std::string &in, const std::string &plain, const std::string &tok)
Simple search and replace function for strings;.
Abstract class to handle sub-systems of the icub-client.
SubSystem_Speech(const std::string &masterName)
Default constructor.
yarp::os::Port tts
Port to /iSpeak.
void SetOptions(const std::string &custom)
Set the command line options sent by iSpeak.
bool isSpeaking()
Check if iSpeak is currently speaking.
virtual void Close()
Clean up resources.