diff --git a/speechInteraction/modules/googleDialog/app/conf/config.ini b/speechInteraction/modules/googleDialog/app/conf/config.ini index e8983ef..5e29df2 100644 --- a/speechInteraction/modules/googleDialog/app/conf/config.ini +++ b/speechInteraction/modules/googleDialog/app/conf/config.ini @@ -1,3 +1,4 @@ name googleDialog language_code en-US sample_rate_hertz 16000 +languageCodes en-US it-IT pt-PT fr-FR en-GB diff --git a/speechInteraction/modules/googleDialog/googleDialog.thrift b/speechInteraction/modules/googleDialog/googleDialog.thrift index 9e6ae42..61cd85d 100644 --- a/speechInteraction/modules/googleDialog/googleDialog.thrift +++ b/speechInteraction/modules/googleDialog/googleDialog.thrift @@ -40,5 +40,19 @@ service googleDialog_IDL * Reset the conversation. */ bool resetDialog(); + + /** + * Set the language of the synthesiser. + * example: setLanguage en-US + * @param string containing the languageCode + * @return true/false on success/failure + */ + bool setLanguage(1:string languageCode); + + /** + * Get the language code of the synthesiser + * @return string containing the language code + */ + string getLanguageCode(); -} \ No newline at end of file +} diff --git a/speechInteraction/modules/googleDialog/main.cpp b/speechInteraction/modules/googleDialog/main.cpp index 54e960f..f126b10 100644 --- a/speechInteraction/modules/googleDialog/main.cpp +++ b/speechInteraction/modules/googleDialog/main.cpp @@ -205,6 +205,19 @@ class Processing : public yarp::os::BufferedPort return result; } + /********************************************************/ + bool setLanguageCode(const std::string &languageCode) + { + language_code = languageCode; + return true; + } + + /********************************************************/ + std::string getLanguageCode() + { + return language_code; + } + /********************************************************/ bool start_acquisition() { @@ -254,6 +267,7 @@ class Module : public yarp::os::RFModule, public googleDialog_IDL friend class processing; bool closing; + std::vector allLanguageCodes; /********************************************************/ bool attach(yarp::os::RpcServer &source) @@ -274,6 +288,15 @@ class Module : public yarp::os::RFModule, public googleDialog_IDL std::string agent_name = rf.check("agent", yarp::os::Value("1"), "name of the agent").asString(); std::string language_code = rf.check("language", yarp::os::Value("en-US"), "language of the dialogflow").asString(); + if (rf.check("languageCodes", "Getting language codes")) + { + yarp::os::Bottle &grp=rf.findGroup("languageCodes"); + int sz=grp.size()-1; + + for (int i=0; isetLanguageCode(languageCode); + returnVal = true; + break; + } + } + + return returnVal; + } + + /********************************************************/ + std::string getLanguageCode() + { + return processing->getLanguageCode(); + } + /**********************************************************/ bool close() { diff --git a/speechInteraction/modules/googleSpeech/app/conf/config.ini b/speechInteraction/modules/googleSpeech/app/conf/config.ini index 103d85a..2a0b750 100644 --- a/speechInteraction/modules/googleSpeech/app/conf/config.ini +++ b/speechInteraction/modules/googleSpeech/app/conf/config.ini @@ -1,3 +1,4 @@ name googleSpeech language_code en-US sample_rate_hertz 16000 +languageCodes en-US it-IT pt-PT fr-FR en-GB diff --git a/speechInteraction/modules/googleSpeech/googleSpeech.thrift b/speechInteraction/modules/googleSpeech/googleSpeech.thrift index cda8889..54ca3ce 100644 --- a/speechInteraction/modules/googleSpeech/googleSpeech.thrift +++ b/speechInteraction/modules/googleSpeech/googleSpeech.thrift @@ -42,4 +42,18 @@ service googleSpeech_IDL * @return a double containing the processing time */ i64 getProcessingTime(); + + /** + * Set the language of the synthesiser. + * example: setLanguage en-US + * @param string containing the languageCode + * @return true/false on success/failure + */ + bool setLanguage(1:string languageCode); + + /** + * Get the language code of the synthesiser + * @return string containing the language code + */ + string getLanguageCode(); } diff --git a/speechInteraction/modules/googleSpeech/main.cpp b/speechInteraction/modules/googleSpeech/main.cpp index 8a9e49a..0629b3f 100644 --- a/speechInteraction/modules/googleSpeech/main.cpp +++ b/speechInteraction/modules/googleSpeech/main.cpp @@ -282,6 +282,19 @@ class Processing : public yarp::os::TypedReaderCallback return b; } + /********************************************************/ + bool setLanguageCode(const std::string &languageCode) + { + language = languageCode; + return true; + } + + /********************************************************/ + std::string getLanguageCode() + { + return language; + } + /********************************************************/ void setArguments(RecognitionConfig* config) { @@ -348,6 +361,7 @@ class Module : public yarp::os::RFModule, public googleSpeech_IDL bool closing; bool uniqueSound; + std::vector allLanguageCodes; /********************************************************/ bool attach(yarp::os::RpcServer &source) @@ -372,6 +386,15 @@ class Module : public yarp::os::RFModule, public googleSpeech_IDL if (rf.check("uniqueSound", "use a yarp::sig::Sound instead of a microphone")) uniqueSound = true; + if (rf.check("languageCodes", "Getting language codes")) + { + yarp::os::Bottle &grp=rf.findGroup("languageCodes"); + int sz=grp.size()-1; + + for (int i=0; isetLanguageCode(languageCode); + returnVal = true; + break; + } + } + + return returnVal; + } + + /********************************************************/ + std::string getLanguageCode() + { + return processing->getLanguageCode(); + } + + /**********************************************************/ bool close() { @@ -477,4 +528,4 @@ int main(int argc, char *argv[]) rf.configure(argc,argv); return module.runModule(rf); -} \ No newline at end of file +}