From 3d07c9a0bfd0d52fb8d35c8f10a8d2831d571e53 Mon Sep 17 00:00:00 2001 From: Ugo Pattacini Date: Wed, 24 Nov 2021 08:31:20 +0100 Subject: [PATCH] upgrade to yarp-3.5.1 --- iSpeak/main.cpp | 38 +++++++++---------- .../start/input/src/start-speech.cpp | 2 +- speechInteraction/CMakeLists.txt | 2 +- .../modules/googleSpeech/main.cpp | 4 +- .../modules/googleSpeechProcess/main.cpp | 12 +++--- .../modules/googleSynthesis/main.cpp | 4 +- .../src/SpeechRecognizerModule.cpp | 20 +++++----- svox-speech/speech.cpp | 4 +- 8 files changed, 43 insertions(+), 43 deletions(-) diff --git a/iSpeak/main.cpp b/iSpeak/main.cpp index 1cbe69a..d813df5 100644 --- a/iSpeak/main.cpp +++ b/iSpeak/main.cpp @@ -109,9 +109,9 @@ class MouthHandler : public PeriodicThread if (emotions.getOutputCount()>0) { Bottle cmd, reply; - cmd.addVocab(Vocab::encode("set")); - cmd.addVocab(Vocab::encode("mou")); - cmd.addVocab(Vocab::encode(state)); + cmd.addVocab32("set"); + cmd.addVocab32("mou"); + cmd.addVocab32(state); emotions.write(cmd,reply); } } @@ -141,7 +141,7 @@ class MouthHandler : public PeriodicThread if (r1.getOutputCount()>0) { Bottle cmd,rep; - cmd.addVocab(Vocab::encode("tstart")); + cmd.addVocab32("tstart"); r1.write(cmd,rep); } @@ -170,7 +170,7 @@ class MouthHandler : public PeriodicThread r1.open("/"+name+"/r1:rpc"); state="sur"; - setPeriod((double)rf.check("period",Value(200)).asInt()/1000.0); + setPeriod((double)rf.check("period",Value(200)).asInt32()/1000.0); } /************************************************************************/ @@ -185,7 +185,7 @@ class MouthHandler : public PeriodicThread if (r1.getOutputCount()>0) { Bottle cmd,rep; - cmd.addVocab(Vocab::encode("tstart")); + cmd.addVocab32("tstart"); r1.write(cmd,rep); } @@ -208,7 +208,7 @@ class MouthHandler : public PeriodicThread if (r1.getOutputCount()>0) { Bottle cmd,rep; - cmd.addVocab(Vocab::encode("tstop")); + cmd.addVocab32("tstop"); r1.write(cmd,rep); } } @@ -335,17 +335,17 @@ class iSpeak : protected BufferedPort, { if (request.get(0).isString()) phrase=request.get(0).asString(); - else if (request.get(0).isDouble() || request.get(0).isInt()) + else if (request.get(0).isFloat64() || request.get(0).isInt32()) { - time=request.get(0).asDouble(); + time=request.get(0).asFloat64(); onlyMouth=true; } if (request.size()>1) { - if (request.get(1).isInt()) + if (request.get(1).isInt32()) { - int newRate=request.get(1).asInt(); + int newRate=request.get(1).asInt32(); if (newRate>0) { mouth.setPeriod((double)newRate/1000.0); @@ -354,8 +354,8 @@ class iSpeak : protected BufferedPort, } if ((request.size()>2) && request.get(0).isString()) - if (request.get(2).isDouble() || request.get(2).isInt()) - duration=request.get(2).asDouble(); + if (request.get(2).isFloat64() || request.get(2).isInt32()) + duration=request.get(2).asFloat64(); } } } @@ -474,8 +474,8 @@ class Launcher: public RFModule /************************************************************************/ bool respond(const Bottle &command, Bottle &reply) { - int cmd0=command.get(0).asVocab(); - if (cmd0==Vocab::encode("stat")) + int cmd0=command.get(0).asVocab32(); + if (cmd0==Vocab32::encode("stat")) { reply.addString(speaker.isSpeaking()?"speaking":"quiet"); return true; @@ -483,10 +483,10 @@ class Launcher: public RFModule if (command.size()>1) { - int cmd1=command.get(1).asVocab(); - if (cmd1==Vocab::encode("opt")) + int cmd1=command.get(1).asVocab32(); + if (cmd1==Vocab32::encode("opt")) { - if (cmd0==Vocab::encode("set")) + if (cmd0==Vocab32::encode("set")) { if (command.size()>2) { @@ -496,7 +496,7 @@ class Launcher: public RFModule return true; } } - else if (cmd0==Vocab::encode("get")) + else if (cmd0==Vocab32::encode("get")) { reply.addString(speaker.get_package_options()); return true; diff --git a/speech-interpreters/start/input/src/start-speech.cpp b/speech-interpreters/start/input/src/start-speech.cpp index b7ae271..92d751f 100644 --- a/speech-interpreters/start/input/src/start-speech.cpp +++ b/speech-interpreters/start/input/src/start-speech.cpp @@ -238,7 +238,7 @@ void STARTManager::onRead(yarp::os::Bottle &bot) { std::string::size_type sz; // alias of size_t int i_dec = std::stoi (words,&sz); - finalTmp.addInt(i_dec); + finalTmp.addInt32(i_dec); } } answer.erase(answer.find_first_of("["), answer.find_first_of("]")); diff --git a/speechInteraction/CMakeLists.txt b/speechInteraction/CMakeLists.txt index a8e02f5..fcb0388 100644 --- a/speechInteraction/CMakeLists.txt +++ b/speechInteraction/CMakeLists.txt @@ -20,7 +20,7 @@ find_package(ICUBcontrib REQUIRED) find_package(Protobuf REQUIRED) find_package(gRPC CONFIG REQUIRED) find_package(GOOGLEAPIS REQUIRED) -find_package(YARP 3.2.1 REQUIRED COMPONENTS OS sig dev math) +find_package(YARP 3.5.1 REQUIRED COMPONENTS OS sig dev math) include_directories(${googleapis_INCLUDE_DIR}) diff --git a/speechInteraction/modules/googleSpeech/main.cpp b/speechInteraction/modules/googleSpeech/main.cpp index e7dba44..ff6fe8b 100644 --- a/speechInteraction/modules/googleSpeech/main.cpp +++ b/speechInteraction/modules/googleSpeech/main.cpp @@ -332,7 +332,7 @@ class Processing : public yarp::os::TypedReaderCallback { std::lock_guard lg(mtx); yarp::os::Bottle cmd, rep; - //cmd.addVocab(yarp::os::Vocab::encode("start")); + //cmd.addVocab32("start"); cmd.addString("start"); if (audioCommand.write(cmd, rep)) { @@ -405,7 +405,7 @@ class Module : public yarp::os::RFModule, public googleSpeech_IDL std::string moduleName = rf.check("name", yarp::os::Value("googleSpeech"), "module name (string)").asString(); std::string language = rf.check("language_code", yarp::os::Value("en-US"), "language (string)").asString(); - int sample_rate = rf.check("sample_rate_hertz", yarp::os::Value(16000), "sample rate (int)").asInt(); + int sample_rate = rf.check("sample_rate_hertz", yarp::os::Value(16000), "sample rate (int)").asInt32(); if (rf.check("uniqueSound", "use a yarp::sig::Sound instead of a microphone")) uniqueSound = true; diff --git a/speechInteraction/modules/googleSpeechProcess/main.cpp b/speechInteraction/modules/googleSpeechProcess/main.cpp index cca1d08..f1f23e4 100644 --- a/speechInteraction/modules/googleSpeechProcess/main.cpp +++ b/speechInteraction/modules/googleSpeechProcess/main.cpp @@ -382,11 +382,11 @@ class Processing : public yarp::os::BufferedPort yarp::os::Bottle &sentiment_score = sentiment.addList(); sentiment_score.addString("Score"); std::pair sentiment_result = read_sentiment( sentiment_sentences ); - sentiment_score.addDouble(sentiment_result.second); + sentiment_score.addFloat64(sentiment_result.second); yarp::os::Bottle &sentiment_magnitude = sentiment.addList(); sentiment_magnitude.addString("Magnitude"); - sentiment_magnitude.addDouble(sentiment_result.first); + sentiment_magnitude.addFloat64(sentiment_result.first); yInfo() << "wordList " << wordList.toString().c_str(); @@ -618,15 +618,15 @@ class Processing : public yarp::os::BufferedPort sentiment_analysis.addString(sentence); //add the sentence yarp::os::Bottle* sentiment = wordList.get(0).asList()->get(element-1).asList(); //yInfo() << "sentiment " << sentiment->toString();//Sentiment (Score 0.100000001490116119385) (Magnitude 0.100000001490116119385) - double score = sentiment->get(1).asList()->get(1).asDouble(); - double magnitude = sentiment->get(2).asList()->get(1).asDouble(); + double score = sentiment->get(1).asList()->get(1).asFloat64(); + double magnitude = sentiment->get(2).asList()->get(1).asFloat64(); //printf("Values: %f %f\n", score, magnitude); yarp::os::Bottle &each_score = sentiment_analysis.addList(); each_score.addString("Score"); //add the corresponding score - each_score.addDouble(score); + each_score.addFloat64(score); yarp::os::Bottle &each_magnitude = sentiment_analysis.addList(); each_magnitude.addString("Magnitude"); //add the corresponding magnitude - each_magnitude.addDouble(magnitude); + each_magnitude.addFloat64(magnitude); diff --git a/speechInteraction/modules/googleSynthesis/main.cpp b/speechInteraction/modules/googleSynthesis/main.cpp index 83228bd..d4babe9 100644 --- a/speechInteraction/modules/googleSynthesis/main.cpp +++ b/speechInteraction/modules/googleSynthesis/main.cpp @@ -316,8 +316,8 @@ class Module : public yarp::os::RFModule, public googleSynthesis_IDL std::string language = rf.check("language", yarp::os::Value("en-US"), "language to use (string)").asString(); std::string voice = rf.check("voice", yarp::os::Value("en-US-Wavenet-D"), "voice to use (string)").asString(); - double speed = rf.check("speed", yarp::os::Value(1.0), "speed to use (double)").asDouble(); - double pitch = rf.check("pitch", yarp::os::Value(0.0), "pitch to use (double)").asDouble(); + double speed = rf.check("speed", yarp::os::Value(1.0), "speed to use (double)").asFloat64(); + double pitch = rf.check("pitch", yarp::os::Value(0.0), "pitch to use (double)").asFloat64(); if (rf.check("languageCodes", "Getting language codes")) { diff --git a/speechRecognizer/src/SpeechRecognizerModule.cpp b/speechRecognizer/src/SpeechRecognizerModule.cpp index f3c2615..1aeada2 100644 --- a/speechRecognizer/src/SpeechRecognizerModule.cpp +++ b/speechRecognizer/src/SpeechRecognizerModule.cpp @@ -53,7 +53,7 @@ std::vector split(const std::string &s, char delim) { bool SpeechRecognizerModule::configure(ResourceFinder &rf ) { setName( rf.check("name",Value("speechRecognizer")).asString().c_str() ); - m_timeout = rf.check("timeout",Value(10000)).asInt(); + m_timeout = rf.check("timeout",Value(10000)).asInt32(); USE_LEGACY = !rf.check("noLegacy"); m_forwardSound = rf.check("forwardSound"); m_tmpFileFolder = rf.getHomeContextPath(); @@ -265,7 +265,7 @@ bool SpeechRecognizerModule::updateModule() //Send over yarp Bottle bOut; bOut.addString(fullSentence); - bOut.addInt(confidence); + bOut.addInt32(confidence); m_portContinuousRecognition.write(bOut); //Treat the semantic @@ -644,7 +644,7 @@ string SpeechRecognizerModule::getFromDictaction(int timeout, LPCWSTR options ) for(list< pair >::iterator it = results.begin(); it != results.end(); it++) { botTmp.addString(it->first); - //botTmp.addDouble(it->second); + //botTmp.addFloat64(it->second); } } yInfo() <<"Dictation is off..."; @@ -662,8 +662,8 @@ bool SpeechRecognizerModule::handleRecognitionCmd(const Bottle& cmd, Bottle& rep if (firstVocab == "timeout") { - m_timeout = cmd.get(1).asInt(); - //reply.addInt(true); + m_timeout = cmd.get(1).asInt32(); + //reply.addInt32(true); return false; } @@ -684,7 +684,7 @@ bool SpeechRecognizerModule::handleRecognitionCmd(const Bottle& cmd, Bottle& rep for(list< pair >::iterator it = results.begin(); it != results.end(); it++) { reply.addString(it->first); - reply.addDouble(it->second); + reply.addFloat64(it->second); } else reply.addString("-1"); @@ -694,7 +694,7 @@ bool SpeechRecognizerModule::handleRecognitionCmd(const Bottle& cmd, Bottle& rep //Turn off dictation and go back to the file grammar everythingIsFine &= SUCCEEDED(m_cpGrammarDictation->SetDictationState( SPRS_INACTIVE )); everythingIsFine &=SUCCEEDED(m_cpGrammarFromFile->SetGrammarState(SPGS_ENABLED)); - //reply.addInt(true); + //reply.addInt32(true); return true; } // If we are not in dictation then we set and switch to the runtimeGrammar @@ -716,7 +716,7 @@ bool SpeechRecognizerModule::handleRecognitionCmd(const Bottle& cmd, Bottle& rep refreshFromVocabulories(m_cpGrammarRuntime); - //reply.addInt(everythingIsFine); + //reply.addInt32(everythingIsFine); } else if (firstVocab == "choices") @@ -758,7 +758,7 @@ bool SpeechRecognizerModule::handleRecognitionCmd(const Bottle& cmd, Bottle& rep for(list< pair >::iterator it = results.begin(); it != results.end(); it++) { reply.addString(it->first); - reply.addDouble(it->second); + reply.addFloat64(it->second); } else reply.addString("-1"); @@ -882,7 +882,7 @@ void SpeechRecognizerModule::say(string s, bool wait) if(wait) { yarp::os::Bottle cmd,reply; - cmd.addVocab(VOCAB('s','t','a','t')); + cmd.addVocab32(VOCAB('s','t','a','t')); std::string status = "speaking"; bool speechStarted = false; while(wait&&(!speechStarted ||status=="speaking")) diff --git a/svox-speech/speech.cpp b/svox-speech/speech.cpp index dcd93ab..159ee48 100644 --- a/svox-speech/speech.cpp +++ b/svox-speech/speech.cpp @@ -82,8 +82,8 @@ bool Speech::open(yarp::os::Searchable &config) return false; } - setPitch(config.check("pitch",Value(90)).asInt()); - setSpeed(config.check("speed",Value(105)).asInt()); + setPitch(config.check("pitch",Value(90)).asInt32()); + setSpeed(config.check("speed",Value(105)).asInt32()); lingwareRF.setDefaultContext(config.check("lingware-context",Value("speech")).asString()); lingwareRF.configure(0,NULL);