Skip to content

Commit 0129410

Browse files
authored
Merge pull request #32 from robotology/feat/makeGoogleiSpeakCompatible
googleSynthesis: make it compatible with iSpeak rpc protocol
2 parents 39b6d70 + 835366b commit 0129410

File tree

1 file changed

+24
-6
lines changed
  • speechInteraction/modules/googleSynthesis

1 file changed

+24
-6
lines changed

speechInteraction/modules/googleSynthesis/main.cpp

+24-6
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Processing : public yarp::os::BufferedPort<yarp::os::Bottle>
5252
std::string language;
5353
std::string voice;
5454
double speed;
55-
double pitch;
55+
double pitch;
5656
yarp::os::RpcServer handlerPort;
5757
yarp::os::Port syncPort;
5858

@@ -229,10 +229,6 @@ class Module : public yarp::os::RFModule, public googleSynthesis_IDL
229229
bool closing;
230230

231231
/********************************************************/
232-
bool attach(yarp::os::RpcServer &source)
233-
{
234-
return this->yarp().attachAsServer(source);
235-
}
236232

237233
public:
238234

@@ -259,11 +255,33 @@ class Module : public yarp::os::RFModule, public googleSynthesis_IDL
259255
/* now start the thread to do the work */
260256
processing->open();
261257

262-
attach(rpcPort);
258+
if(!attach(rpcPort)) {
259+
yError()<<"Cannot attach to rpc port";
260+
return false;
261+
}
263262

264263
return true;
265264
}
266265

266+
bool respond(const yarp::os::Bottle& command, yarp::os::Bottle& reply) override
267+
{
268+
auto cmd0=command.get(0).asString();
269+
if (cmd0!="say")
270+
{
271+
reply.addString("Command not recognized, please specify \"say <sentence>\"");
272+
return false;
273+
}
274+
275+
if (command.size()>1)
276+
{
277+
yarp::os::Bottle sentence_bot;
278+
sentence_bot.addString(command.get(1).asString());
279+
processing->queryGoogleSynthesis(sentence_bot);
280+
reply.addString("ack");
281+
}
282+
283+
return yarp::os::RFModule::respond(command,reply);
284+
}
267285
/**********************************************************/
268286
bool close()
269287
{

0 commit comments

Comments
 (0)