diff --git a/doc/release/yarp_3_8/speech_interfaces.md b/doc/release/yarp_3_8/speech_interfaces.md new file mode 100644 index 0000000000..83e0ce9a6a --- /dev/null +++ b/doc/release/yarp_3_8/speech_interfaces.md @@ -0,0 +1,12 @@ +speech_interfaces {#master} +----------- + +### libYarp_dev + +* added interfaces: ISpeechSynthesizer, ISpeechTranscription + +### devices + +* added plugins: devices fakeSpeechSynthesizer, fakeSpeechTranscription + tests +* added nws devices: speechSynthesizer_nws_yarp, speechTranscription_nws_yarp + tests + diff --git a/src/devices/CMakeLists.txt b/src/devices/CMakeLists.txt index 226c74738d..5ea62c9b96 100644 --- a/src/devices/CMakeLists.txt +++ b/src/devices/CMakeLists.txt @@ -26,6 +26,8 @@ yarp_begin_plugin_library(yarpmod add_subdirectory(fakeOdometry2D) add_subdirectory(fakePositionSensor) add_subdirectory(fakeSerialPort) + add_subdirectory(fakeSpeechSynthesizer) + add_subdirectory(fakeSpeechTranscription) add_subdirectory(frameTransformClient) add_subdirectory(frameTransformGet) add_subdirectory(frameTransformServer) @@ -48,6 +50,8 @@ yarp_begin_plugin_library(yarpmod add_subdirectory(ILocalization2DMsgs) add_subdirectory(IOdometry2DMsgs) add_subdirectory(ISerialMsgs) + add_subdirectory(ISpeechSynthesizerMsgs) + add_subdirectory(ISpeechTranscriptionMsgs) add_subdirectory(DynamixelAX12Ftdi) add_subdirectory(fakeLaser) add_subdirectory(fakeLaserWithMotor) @@ -85,6 +89,8 @@ yarp_begin_plugin_library(yarpmod add_subdirectory(fakeNavigationDevice) add_subdirectory(serialPort_nws_yarp) add_subdirectory(serialPort_nwc_yarp) + add_subdirectory(speechSynthesizer_nws_yarp) + add_subdirectory(speechTranscription_nws_yarp) add_subdirectory(RemoteControlBoard) add_subdirectory(AnalogSensorClient) add_subdirectory(AnalogWrapper) diff --git a/src/devices/ISpeechSynthesizerMsgs/CMakeLists.txt b/src/devices/ISpeechSynthesizerMsgs/CMakeLists.txt new file mode 100644 index 0000000000..96a9928ad4 --- /dev/null +++ b/src/devices/ISpeechSynthesizerMsgs/CMakeLists.txt @@ -0,0 +1,24 @@ +# SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) +# SPDX-License-Identifier: BSD-3-Clause + +if(NOT YARP_COMPILE_DEVICE_PLUGINS) + return() +endif() + +include(YarpChooseIDL) +yarp_choose_idl(ISPEECHTRANSCMSG_THRIFT ISpeechSynthesizerMsgs.thrift) + +add_library(ISpeechSynthesizerMsgs OBJECT) + +target_sources(ISpeechSynthesizerMsgs PRIVATE ${ISPEECHTRANSCMSG_THRIFT_GEN_FILES}) + +target_link_libraries(ISpeechSynthesizerMsgs + PRIVATE + YARP::YARP_dev + YARP::YARP_os + YARP::YARP_sig +) + +target_include_directories(ISpeechSynthesizerMsgs PUBLIC ${ISPEECHTRANSCMSG_THRIFT_BUILD_INTERFACE_INCLUDE_DIRS}) + +set_property(TARGET ISpeechSynthesizerMsgs PROPERTY FOLDER "Devices/Shared") diff --git a/src/devices/ISpeechSynthesizerMsgs/ISpeechSynthesizerMsgs.thrift b/src/devices/ISpeechSynthesizerMsgs/ISpeechSynthesizerMsgs.thrift new file mode 100644 index 0000000000..f075a65470 --- /dev/null +++ b/src/devices/ISpeechSynthesizerMsgs/ISpeechSynthesizerMsgs.thrift @@ -0,0 +1,48 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +struct yarp_sig_Sound { +} ( + yarp.name = "yarp::sig::Sound" + yarp.includefile = "yarp/sig/Sound.h" +) + +struct return_get_language { + 1: bool ret = false; + 2: string language; +} + +struct return_get_voice { + 1: bool ret = false; + 2: string voice; +} + +struct return_get_speed { + 1: bool ret = false; + 2: double speed; +} + +struct return_get_pitch { + 1: bool ret = false; + 2: double pitch; +} + +struct return_synthesize { + 1: bool ret = false; + 2: yarp_sig_Sound sound; +} + +service ISpeechSynthesizerMsgs +{ + bool set_language (1:string language); + return_get_language get_language (); + bool set_voice (1:string language); + return_get_voice get_voice (); + bool set_speed (1:double speed); + return_get_speed get_speed (); + bool set_pitch (1:double pitch); + return_get_pitch get_pitch (); + return_synthesize synthesize (1:string text); +} diff --git a/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/ISpeechSynthesizerMsgs.cpp b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/ISpeechSynthesizerMsgs.cpp new file mode 100644 index 0000000000..609195838f --- /dev/null +++ b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/ISpeechSynthesizerMsgs.cpp @@ -0,0 +1,2215 @@ +/* + * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +// Autogenerated by Thrift Compiler (0.14.1-yarped) +// +// This is an automatically generated file. +// It could get re-generated if the ALLOW_IDL_GENERATION flag is on. + +#include + +#include + +#include + +// set_language helper class declaration +class ISpeechSynthesizerMsgs_set_language_helper : + public yarp::os::Portable +{ +public: + ISpeechSynthesizerMsgs_set_language_helper() = default; + explicit ISpeechSynthesizerMsgs_set_language_helper(const std::string& language); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + class Command : + public yarp::os::idl::WirePortable + { + public: + Command() = default; + explicit Command(const std::string& language); + + ~Command() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool writeTag(const yarp::os::idl::WireWriter& writer) const; + bool writeArgs(const yarp::os::idl::WireWriter& writer) const; + + bool read(yarp::os::idl::WireReader& reader) override; + bool readTag(yarp::os::idl::WireReader& reader); + bool readArgs(yarp::os::idl::WireReader& reader); + + std::string language{}; + }; + + class Reply : + public yarp::os::idl::WirePortable + { + public: + Reply() = default; + ~Reply() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool read(yarp::os::idl::WireReader& reader) override; + + bool return_helper{false}; + }; + + using funcptr_t = bool (*)(const std::string&); + void call(ISpeechSynthesizerMsgs* ptr); + + Command cmd; + Reply reply; + + static constexpr const char* s_tag{"set_language"}; + static constexpr size_t s_tag_len{2}; + static constexpr size_t s_cmd_len{3}; + static constexpr size_t s_reply_len{1}; + static constexpr const char* s_prototype{"bool ISpeechSynthesizerMsgs::set_language(const std::string& language)"}; + static constexpr const char* s_help{""}; +}; + +// get_language helper class declaration +class ISpeechSynthesizerMsgs_get_language_helper : + public yarp::os::Portable +{ +public: + ISpeechSynthesizerMsgs_get_language_helper() = default; + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + class Command : + public yarp::os::idl::WirePortable + { + public: + Command() = default; + ~Command() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool writeTag(const yarp::os::idl::WireWriter& writer) const; + bool writeArgs(const yarp::os::idl::WireWriter& writer) const; + + bool read(yarp::os::idl::WireReader& reader) override; + bool readTag(yarp::os::idl::WireReader& reader); + bool readArgs(yarp::os::idl::WireReader& reader); + }; + + class Reply : + public yarp::os::idl::WirePortable + { + public: + Reply() = default; + ~Reply() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool read(yarp::os::idl::WireReader& reader) override; + + return_get_language return_helper{}; + }; + + using funcptr_t = return_get_language (*)(); + void call(ISpeechSynthesizerMsgs* ptr); + + Command cmd; + Reply reply; + + static constexpr const char* s_tag{"get_language"}; + static constexpr size_t s_tag_len{2}; + static constexpr size_t s_cmd_len{2}; + static constexpr size_t s_reply_len{2}; + static constexpr const char* s_prototype{"return_get_language ISpeechSynthesizerMsgs::get_language()"}; + static constexpr const char* s_help{""}; +}; + +// set_voice helper class declaration +class ISpeechSynthesizerMsgs_set_voice_helper : + public yarp::os::Portable +{ +public: + ISpeechSynthesizerMsgs_set_voice_helper() = default; + explicit ISpeechSynthesizerMsgs_set_voice_helper(const std::string& language); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + class Command : + public yarp::os::idl::WirePortable + { + public: + Command() = default; + explicit Command(const std::string& language); + + ~Command() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool writeTag(const yarp::os::idl::WireWriter& writer) const; + bool writeArgs(const yarp::os::idl::WireWriter& writer) const; + + bool read(yarp::os::idl::WireReader& reader) override; + bool readTag(yarp::os::idl::WireReader& reader); + bool readArgs(yarp::os::idl::WireReader& reader); + + std::string language{}; + }; + + class Reply : + public yarp::os::idl::WirePortable + { + public: + Reply() = default; + ~Reply() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool read(yarp::os::idl::WireReader& reader) override; + + bool return_helper{false}; + }; + + using funcptr_t = bool (*)(const std::string&); + void call(ISpeechSynthesizerMsgs* ptr); + + Command cmd; + Reply reply; + + static constexpr const char* s_tag{"set_voice"}; + static constexpr size_t s_tag_len{2}; + static constexpr size_t s_cmd_len{3}; + static constexpr size_t s_reply_len{1}; + static constexpr const char* s_prototype{"bool ISpeechSynthesizerMsgs::set_voice(const std::string& language)"}; + static constexpr const char* s_help{""}; +}; + +// get_voice helper class declaration +class ISpeechSynthesizerMsgs_get_voice_helper : + public yarp::os::Portable +{ +public: + ISpeechSynthesizerMsgs_get_voice_helper() = default; + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + class Command : + public yarp::os::idl::WirePortable + { + public: + Command() = default; + ~Command() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool writeTag(const yarp::os::idl::WireWriter& writer) const; + bool writeArgs(const yarp::os::idl::WireWriter& writer) const; + + bool read(yarp::os::idl::WireReader& reader) override; + bool readTag(yarp::os::idl::WireReader& reader); + bool readArgs(yarp::os::idl::WireReader& reader); + }; + + class Reply : + public yarp::os::idl::WirePortable + { + public: + Reply() = default; + ~Reply() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool read(yarp::os::idl::WireReader& reader) override; + + return_get_voice return_helper{}; + }; + + using funcptr_t = return_get_voice (*)(); + void call(ISpeechSynthesizerMsgs* ptr); + + Command cmd; + Reply reply; + + static constexpr const char* s_tag{"get_voice"}; + static constexpr size_t s_tag_len{2}; + static constexpr size_t s_cmd_len{2}; + static constexpr size_t s_reply_len{2}; + static constexpr const char* s_prototype{"return_get_voice ISpeechSynthesizerMsgs::get_voice()"}; + static constexpr const char* s_help{""}; +}; + +// set_speed helper class declaration +class ISpeechSynthesizerMsgs_set_speed_helper : + public yarp::os::Portable +{ +public: + ISpeechSynthesizerMsgs_set_speed_helper() = default; + explicit ISpeechSynthesizerMsgs_set_speed_helper(const double speed); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + class Command : + public yarp::os::idl::WirePortable + { + public: + Command() = default; + explicit Command(const double speed); + + ~Command() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool writeTag(const yarp::os::idl::WireWriter& writer) const; + bool writeArgs(const yarp::os::idl::WireWriter& writer) const; + + bool read(yarp::os::idl::WireReader& reader) override; + bool readTag(yarp::os::idl::WireReader& reader); + bool readArgs(yarp::os::idl::WireReader& reader); + + double speed{0.0}; + }; + + class Reply : + public yarp::os::idl::WirePortable + { + public: + Reply() = default; + ~Reply() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool read(yarp::os::idl::WireReader& reader) override; + + bool return_helper{false}; + }; + + using funcptr_t = bool (*)(const double); + void call(ISpeechSynthesizerMsgs* ptr); + + Command cmd; + Reply reply; + + static constexpr const char* s_tag{"set_speed"}; + static constexpr size_t s_tag_len{2}; + static constexpr size_t s_cmd_len{3}; + static constexpr size_t s_reply_len{1}; + static constexpr const char* s_prototype{"bool ISpeechSynthesizerMsgs::set_speed(const double speed)"}; + static constexpr const char* s_help{""}; +}; + +// get_speed helper class declaration +class ISpeechSynthesizerMsgs_get_speed_helper : + public yarp::os::Portable +{ +public: + ISpeechSynthesizerMsgs_get_speed_helper() = default; + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + class Command : + public yarp::os::idl::WirePortable + { + public: + Command() = default; + ~Command() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool writeTag(const yarp::os::idl::WireWriter& writer) const; + bool writeArgs(const yarp::os::idl::WireWriter& writer) const; + + bool read(yarp::os::idl::WireReader& reader) override; + bool readTag(yarp::os::idl::WireReader& reader); + bool readArgs(yarp::os::idl::WireReader& reader); + }; + + class Reply : + public yarp::os::idl::WirePortable + { + public: + Reply() = default; + ~Reply() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool read(yarp::os::idl::WireReader& reader) override; + + return_get_speed return_helper{}; + }; + + using funcptr_t = return_get_speed (*)(); + void call(ISpeechSynthesizerMsgs* ptr); + + Command cmd; + Reply reply; + + static constexpr const char* s_tag{"get_speed"}; + static constexpr size_t s_tag_len{2}; + static constexpr size_t s_cmd_len{2}; + static constexpr size_t s_reply_len{2}; + static constexpr const char* s_prototype{"return_get_speed ISpeechSynthesizerMsgs::get_speed()"}; + static constexpr const char* s_help{""}; +}; + +// set_pitch helper class declaration +class ISpeechSynthesizerMsgs_set_pitch_helper : + public yarp::os::Portable +{ +public: + ISpeechSynthesizerMsgs_set_pitch_helper() = default; + explicit ISpeechSynthesizerMsgs_set_pitch_helper(const double pitch); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + class Command : + public yarp::os::idl::WirePortable + { + public: + Command() = default; + explicit Command(const double pitch); + + ~Command() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool writeTag(const yarp::os::idl::WireWriter& writer) const; + bool writeArgs(const yarp::os::idl::WireWriter& writer) const; + + bool read(yarp::os::idl::WireReader& reader) override; + bool readTag(yarp::os::idl::WireReader& reader); + bool readArgs(yarp::os::idl::WireReader& reader); + + double pitch{0.0}; + }; + + class Reply : + public yarp::os::idl::WirePortable + { + public: + Reply() = default; + ~Reply() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool read(yarp::os::idl::WireReader& reader) override; + + bool return_helper{false}; + }; + + using funcptr_t = bool (*)(const double); + void call(ISpeechSynthesizerMsgs* ptr); + + Command cmd; + Reply reply; + + static constexpr const char* s_tag{"set_pitch"}; + static constexpr size_t s_tag_len{2}; + static constexpr size_t s_cmd_len{3}; + static constexpr size_t s_reply_len{1}; + static constexpr const char* s_prototype{"bool ISpeechSynthesizerMsgs::set_pitch(const double pitch)"}; + static constexpr const char* s_help{""}; +}; + +// get_pitch helper class declaration +class ISpeechSynthesizerMsgs_get_pitch_helper : + public yarp::os::Portable +{ +public: + ISpeechSynthesizerMsgs_get_pitch_helper() = default; + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + class Command : + public yarp::os::idl::WirePortable + { + public: + Command() = default; + ~Command() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool writeTag(const yarp::os::idl::WireWriter& writer) const; + bool writeArgs(const yarp::os::idl::WireWriter& writer) const; + + bool read(yarp::os::idl::WireReader& reader) override; + bool readTag(yarp::os::idl::WireReader& reader); + bool readArgs(yarp::os::idl::WireReader& reader); + }; + + class Reply : + public yarp::os::idl::WirePortable + { + public: + Reply() = default; + ~Reply() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool read(yarp::os::idl::WireReader& reader) override; + + return_get_pitch return_helper{}; + }; + + using funcptr_t = return_get_pitch (*)(); + void call(ISpeechSynthesizerMsgs* ptr); + + Command cmd; + Reply reply; + + static constexpr const char* s_tag{"get_pitch"}; + static constexpr size_t s_tag_len{2}; + static constexpr size_t s_cmd_len{2}; + static constexpr size_t s_reply_len{2}; + static constexpr const char* s_prototype{"return_get_pitch ISpeechSynthesizerMsgs::get_pitch()"}; + static constexpr const char* s_help{""}; +}; + +// synthesize helper class declaration +class ISpeechSynthesizerMsgs_synthesize_helper : + public yarp::os::Portable +{ +public: + ISpeechSynthesizerMsgs_synthesize_helper() = default; + explicit ISpeechSynthesizerMsgs_synthesize_helper(const std::string& text); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + class Command : + public yarp::os::idl::WirePortable + { + public: + Command() = default; + explicit Command(const std::string& text); + + ~Command() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool writeTag(const yarp::os::idl::WireWriter& writer) const; + bool writeArgs(const yarp::os::idl::WireWriter& writer) const; + + bool read(yarp::os::idl::WireReader& reader) override; + bool readTag(yarp::os::idl::WireReader& reader); + bool readArgs(yarp::os::idl::WireReader& reader); + + std::string text{}; + }; + + class Reply : + public yarp::os::idl::WirePortable + { + public: + Reply() = default; + ~Reply() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool read(yarp::os::idl::WireReader& reader) override; + + return_synthesize return_helper{}; + }; + + using funcptr_t = return_synthesize (*)(const std::string&); + void call(ISpeechSynthesizerMsgs* ptr); + + Command cmd; + Reply reply; + + static constexpr const char* s_tag{"synthesize"}; + static constexpr size_t s_tag_len{1}; + static constexpr size_t s_cmd_len{2}; + static constexpr size_t s_reply_len{2}; + static constexpr const char* s_prototype{"return_synthesize ISpeechSynthesizerMsgs::synthesize(const std::string& text)"}; + static constexpr const char* s_help{""}; +}; + +// set_language helper class implementation +ISpeechSynthesizerMsgs_set_language_helper::ISpeechSynthesizerMsgs_set_language_helper(const std::string& language) : + cmd{language} +{ +} + +bool ISpeechSynthesizerMsgs_set_language_helper::write(yarp::os::ConnectionWriter& connection) const +{ + return cmd.write(connection); +} + +bool ISpeechSynthesizerMsgs_set_language_helper::read(yarp::os::ConnectionReader& connection) +{ + return reply.read(connection); +} + +ISpeechSynthesizerMsgs_set_language_helper::Command::Command(const std::string& language) : + language{language} +{ +} + +bool ISpeechSynthesizerMsgs_set_language_helper::Command::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(s_cmd_len)) { + return false; + } + return write(writer); +} + +bool ISpeechSynthesizerMsgs_set_language_helper::Command::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListHeader()) { + reader.fail(); + return false; + } + return read(reader); +} + +bool ISpeechSynthesizerMsgs_set_language_helper::Command::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writeTag(writer)) { + return false; + } + if (!writeArgs(writer)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_language_helper::Command::writeTag(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeTag(s_tag, 1, s_tag_len)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_language_helper::Command::writeArgs(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeString(language)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_language_helper::Command::read(yarp::os::idl::WireReader& reader) +{ + if (!readTag(reader)) { + return false; + } + if (!readArgs(reader)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_language_helper::Command::readTag(yarp::os::idl::WireReader& reader) +{ + std::string tag = reader.readTag(s_tag_len); + if (reader.isError()) { + return false; + } + if (tag != s_tag) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_language_helper::Command::readArgs(yarp::os::idl::WireReader& reader) +{ + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readString(language)) { + reader.fail(); + return false; + } + if (!reader.noMore()) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_language_helper::Reply::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + return write(writer); +} + +bool ISpeechSynthesizerMsgs_set_language_helper::Reply::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + return read(reader); +} + +bool ISpeechSynthesizerMsgs_set_language_helper::Reply::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.isNull()) { + if (!writer.writeListHeader(s_reply_len)) { + return false; + } + if (!writer.writeBool(return_helper)) { + return false; + } + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_language_helper::Reply::read(yarp::os::idl::WireReader& reader) +{ + if (!reader.readListReturn()) { + return false; + } + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readBool(return_helper)) { + reader.fail(); + return false; + } + return true; +} + +void ISpeechSynthesizerMsgs_set_language_helper::call(ISpeechSynthesizerMsgs* ptr) +{ + reply.return_helper = ptr->set_language(cmd.language); +} + +// get_language helper class implementation +bool ISpeechSynthesizerMsgs_get_language_helper::write(yarp::os::ConnectionWriter& connection) const +{ + return cmd.write(connection); +} + +bool ISpeechSynthesizerMsgs_get_language_helper::read(yarp::os::ConnectionReader& connection) +{ + return reply.read(connection); +} + +bool ISpeechSynthesizerMsgs_get_language_helper::Command::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(s_cmd_len)) { + return false; + } + return write(writer); +} + +bool ISpeechSynthesizerMsgs_get_language_helper::Command::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListHeader()) { + reader.fail(); + return false; + } + return read(reader); +} + +bool ISpeechSynthesizerMsgs_get_language_helper::Command::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writeTag(writer)) { + return false; + } + if (!writeArgs(writer)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_language_helper::Command::writeTag(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeTag(s_tag, 1, s_tag_len)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_language_helper::Command::writeArgs(const yarp::os::idl::WireWriter& writer [[maybe_unused]]) const +{ + return true; +} + +bool ISpeechSynthesizerMsgs_get_language_helper::Command::read(yarp::os::idl::WireReader& reader) +{ + if (!readTag(reader)) { + return false; + } + if (!readArgs(reader)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_language_helper::Command::readTag(yarp::os::idl::WireReader& reader) +{ + std::string tag = reader.readTag(s_tag_len); + if (reader.isError()) { + return false; + } + if (tag != s_tag) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_language_helper::Command::readArgs(yarp::os::idl::WireReader& reader) +{ + if (!reader.noMore()) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_language_helper::Reply::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + return write(writer); +} + +bool ISpeechSynthesizerMsgs_get_language_helper::Reply::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + return read(reader); +} + +bool ISpeechSynthesizerMsgs_get_language_helper::Reply::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.isNull()) { + if (!writer.writeListHeader(s_reply_len)) { + return false; + } + if (!writer.write(return_helper)) { + return false; + } + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_language_helper::Reply::read(yarp::os::idl::WireReader& reader) +{ + if (!reader.readListReturn()) { + return false; + } + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.read(return_helper)) { + reader.fail(); + return false; + } + return true; +} + +void ISpeechSynthesizerMsgs_get_language_helper::call(ISpeechSynthesizerMsgs* ptr) +{ + reply.return_helper = ptr->get_language(); +} + +// set_voice helper class implementation +ISpeechSynthesizerMsgs_set_voice_helper::ISpeechSynthesizerMsgs_set_voice_helper(const std::string& language) : + cmd{language} +{ +} + +bool ISpeechSynthesizerMsgs_set_voice_helper::write(yarp::os::ConnectionWriter& connection) const +{ + return cmd.write(connection); +} + +bool ISpeechSynthesizerMsgs_set_voice_helper::read(yarp::os::ConnectionReader& connection) +{ + return reply.read(connection); +} + +ISpeechSynthesizerMsgs_set_voice_helper::Command::Command(const std::string& language) : + language{language} +{ +} + +bool ISpeechSynthesizerMsgs_set_voice_helper::Command::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(s_cmd_len)) { + return false; + } + return write(writer); +} + +bool ISpeechSynthesizerMsgs_set_voice_helper::Command::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListHeader()) { + reader.fail(); + return false; + } + return read(reader); +} + +bool ISpeechSynthesizerMsgs_set_voice_helper::Command::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writeTag(writer)) { + return false; + } + if (!writeArgs(writer)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_voice_helper::Command::writeTag(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeTag(s_tag, 1, s_tag_len)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_voice_helper::Command::writeArgs(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeString(language)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_voice_helper::Command::read(yarp::os::idl::WireReader& reader) +{ + if (!readTag(reader)) { + return false; + } + if (!readArgs(reader)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_voice_helper::Command::readTag(yarp::os::idl::WireReader& reader) +{ + std::string tag = reader.readTag(s_tag_len); + if (reader.isError()) { + return false; + } + if (tag != s_tag) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_voice_helper::Command::readArgs(yarp::os::idl::WireReader& reader) +{ + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readString(language)) { + reader.fail(); + return false; + } + if (!reader.noMore()) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_voice_helper::Reply::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + return write(writer); +} + +bool ISpeechSynthesizerMsgs_set_voice_helper::Reply::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + return read(reader); +} + +bool ISpeechSynthesizerMsgs_set_voice_helper::Reply::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.isNull()) { + if (!writer.writeListHeader(s_reply_len)) { + return false; + } + if (!writer.writeBool(return_helper)) { + return false; + } + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_voice_helper::Reply::read(yarp::os::idl::WireReader& reader) +{ + if (!reader.readListReturn()) { + return false; + } + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readBool(return_helper)) { + reader.fail(); + return false; + } + return true; +} + +void ISpeechSynthesizerMsgs_set_voice_helper::call(ISpeechSynthesizerMsgs* ptr) +{ + reply.return_helper = ptr->set_voice(cmd.language); +} + +// get_voice helper class implementation +bool ISpeechSynthesizerMsgs_get_voice_helper::write(yarp::os::ConnectionWriter& connection) const +{ + return cmd.write(connection); +} + +bool ISpeechSynthesizerMsgs_get_voice_helper::read(yarp::os::ConnectionReader& connection) +{ + return reply.read(connection); +} + +bool ISpeechSynthesizerMsgs_get_voice_helper::Command::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(s_cmd_len)) { + return false; + } + return write(writer); +} + +bool ISpeechSynthesizerMsgs_get_voice_helper::Command::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListHeader()) { + reader.fail(); + return false; + } + return read(reader); +} + +bool ISpeechSynthesizerMsgs_get_voice_helper::Command::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writeTag(writer)) { + return false; + } + if (!writeArgs(writer)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_voice_helper::Command::writeTag(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeTag(s_tag, 1, s_tag_len)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_voice_helper::Command::writeArgs(const yarp::os::idl::WireWriter& writer [[maybe_unused]]) const +{ + return true; +} + +bool ISpeechSynthesizerMsgs_get_voice_helper::Command::read(yarp::os::idl::WireReader& reader) +{ + if (!readTag(reader)) { + return false; + } + if (!readArgs(reader)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_voice_helper::Command::readTag(yarp::os::idl::WireReader& reader) +{ + std::string tag = reader.readTag(s_tag_len); + if (reader.isError()) { + return false; + } + if (tag != s_tag) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_voice_helper::Command::readArgs(yarp::os::idl::WireReader& reader) +{ + if (!reader.noMore()) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_voice_helper::Reply::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + return write(writer); +} + +bool ISpeechSynthesizerMsgs_get_voice_helper::Reply::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + return read(reader); +} + +bool ISpeechSynthesizerMsgs_get_voice_helper::Reply::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.isNull()) { + if (!writer.writeListHeader(s_reply_len)) { + return false; + } + if (!writer.write(return_helper)) { + return false; + } + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_voice_helper::Reply::read(yarp::os::idl::WireReader& reader) +{ + if (!reader.readListReturn()) { + return false; + } + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.read(return_helper)) { + reader.fail(); + return false; + } + return true; +} + +void ISpeechSynthesizerMsgs_get_voice_helper::call(ISpeechSynthesizerMsgs* ptr) +{ + reply.return_helper = ptr->get_voice(); +} + +// set_speed helper class implementation +ISpeechSynthesizerMsgs_set_speed_helper::ISpeechSynthesizerMsgs_set_speed_helper(const double speed) : + cmd{speed} +{ +} + +bool ISpeechSynthesizerMsgs_set_speed_helper::write(yarp::os::ConnectionWriter& connection) const +{ + return cmd.write(connection); +} + +bool ISpeechSynthesizerMsgs_set_speed_helper::read(yarp::os::ConnectionReader& connection) +{ + return reply.read(connection); +} + +ISpeechSynthesizerMsgs_set_speed_helper::Command::Command(const double speed) : + speed{speed} +{ +} + +bool ISpeechSynthesizerMsgs_set_speed_helper::Command::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(s_cmd_len)) { + return false; + } + return write(writer); +} + +bool ISpeechSynthesizerMsgs_set_speed_helper::Command::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListHeader()) { + reader.fail(); + return false; + } + return read(reader); +} + +bool ISpeechSynthesizerMsgs_set_speed_helper::Command::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writeTag(writer)) { + return false; + } + if (!writeArgs(writer)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_speed_helper::Command::writeTag(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeTag(s_tag, 1, s_tag_len)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_speed_helper::Command::writeArgs(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeFloat64(speed)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_speed_helper::Command::read(yarp::os::idl::WireReader& reader) +{ + if (!readTag(reader)) { + return false; + } + if (!readArgs(reader)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_speed_helper::Command::readTag(yarp::os::idl::WireReader& reader) +{ + std::string tag = reader.readTag(s_tag_len); + if (reader.isError()) { + return false; + } + if (tag != s_tag) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_speed_helper::Command::readArgs(yarp::os::idl::WireReader& reader) +{ + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readFloat64(speed)) { + reader.fail(); + return false; + } + if (!reader.noMore()) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_speed_helper::Reply::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + return write(writer); +} + +bool ISpeechSynthesizerMsgs_set_speed_helper::Reply::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + return read(reader); +} + +bool ISpeechSynthesizerMsgs_set_speed_helper::Reply::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.isNull()) { + if (!writer.writeListHeader(s_reply_len)) { + return false; + } + if (!writer.writeBool(return_helper)) { + return false; + } + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_speed_helper::Reply::read(yarp::os::idl::WireReader& reader) +{ + if (!reader.readListReturn()) { + return false; + } + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readBool(return_helper)) { + reader.fail(); + return false; + } + return true; +} + +void ISpeechSynthesizerMsgs_set_speed_helper::call(ISpeechSynthesizerMsgs* ptr) +{ + reply.return_helper = ptr->set_speed(cmd.speed); +} + +// get_speed helper class implementation +bool ISpeechSynthesizerMsgs_get_speed_helper::write(yarp::os::ConnectionWriter& connection) const +{ + return cmd.write(connection); +} + +bool ISpeechSynthesizerMsgs_get_speed_helper::read(yarp::os::ConnectionReader& connection) +{ + return reply.read(connection); +} + +bool ISpeechSynthesizerMsgs_get_speed_helper::Command::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(s_cmd_len)) { + return false; + } + return write(writer); +} + +bool ISpeechSynthesizerMsgs_get_speed_helper::Command::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListHeader()) { + reader.fail(); + return false; + } + return read(reader); +} + +bool ISpeechSynthesizerMsgs_get_speed_helper::Command::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writeTag(writer)) { + return false; + } + if (!writeArgs(writer)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_speed_helper::Command::writeTag(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeTag(s_tag, 1, s_tag_len)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_speed_helper::Command::writeArgs(const yarp::os::idl::WireWriter& writer [[maybe_unused]]) const +{ + return true; +} + +bool ISpeechSynthesizerMsgs_get_speed_helper::Command::read(yarp::os::idl::WireReader& reader) +{ + if (!readTag(reader)) { + return false; + } + if (!readArgs(reader)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_speed_helper::Command::readTag(yarp::os::idl::WireReader& reader) +{ + std::string tag = reader.readTag(s_tag_len); + if (reader.isError()) { + return false; + } + if (tag != s_tag) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_speed_helper::Command::readArgs(yarp::os::idl::WireReader& reader) +{ + if (!reader.noMore()) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_speed_helper::Reply::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + return write(writer); +} + +bool ISpeechSynthesizerMsgs_get_speed_helper::Reply::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + return read(reader); +} + +bool ISpeechSynthesizerMsgs_get_speed_helper::Reply::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.isNull()) { + if (!writer.writeListHeader(s_reply_len)) { + return false; + } + if (!writer.write(return_helper)) { + return false; + } + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_speed_helper::Reply::read(yarp::os::idl::WireReader& reader) +{ + if (!reader.readListReturn()) { + return false; + } + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.read(return_helper)) { + reader.fail(); + return false; + } + return true; +} + +void ISpeechSynthesizerMsgs_get_speed_helper::call(ISpeechSynthesizerMsgs* ptr) +{ + reply.return_helper = ptr->get_speed(); +} + +// set_pitch helper class implementation +ISpeechSynthesizerMsgs_set_pitch_helper::ISpeechSynthesizerMsgs_set_pitch_helper(const double pitch) : + cmd{pitch} +{ +} + +bool ISpeechSynthesizerMsgs_set_pitch_helper::write(yarp::os::ConnectionWriter& connection) const +{ + return cmd.write(connection); +} + +bool ISpeechSynthesizerMsgs_set_pitch_helper::read(yarp::os::ConnectionReader& connection) +{ + return reply.read(connection); +} + +ISpeechSynthesizerMsgs_set_pitch_helper::Command::Command(const double pitch) : + pitch{pitch} +{ +} + +bool ISpeechSynthesizerMsgs_set_pitch_helper::Command::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(s_cmd_len)) { + return false; + } + return write(writer); +} + +bool ISpeechSynthesizerMsgs_set_pitch_helper::Command::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListHeader()) { + reader.fail(); + return false; + } + return read(reader); +} + +bool ISpeechSynthesizerMsgs_set_pitch_helper::Command::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writeTag(writer)) { + return false; + } + if (!writeArgs(writer)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_pitch_helper::Command::writeTag(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeTag(s_tag, 1, s_tag_len)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_pitch_helper::Command::writeArgs(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeFloat64(pitch)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_pitch_helper::Command::read(yarp::os::idl::WireReader& reader) +{ + if (!readTag(reader)) { + return false; + } + if (!readArgs(reader)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_pitch_helper::Command::readTag(yarp::os::idl::WireReader& reader) +{ + std::string tag = reader.readTag(s_tag_len); + if (reader.isError()) { + return false; + } + if (tag != s_tag) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_pitch_helper::Command::readArgs(yarp::os::idl::WireReader& reader) +{ + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readFloat64(pitch)) { + reader.fail(); + return false; + } + if (!reader.noMore()) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_pitch_helper::Reply::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + return write(writer); +} + +bool ISpeechSynthesizerMsgs_set_pitch_helper::Reply::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + return read(reader); +} + +bool ISpeechSynthesizerMsgs_set_pitch_helper::Reply::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.isNull()) { + if (!writer.writeListHeader(s_reply_len)) { + return false; + } + if (!writer.writeBool(return_helper)) { + return false; + } + } + return true; +} + +bool ISpeechSynthesizerMsgs_set_pitch_helper::Reply::read(yarp::os::idl::WireReader& reader) +{ + if (!reader.readListReturn()) { + return false; + } + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readBool(return_helper)) { + reader.fail(); + return false; + } + return true; +} + +void ISpeechSynthesizerMsgs_set_pitch_helper::call(ISpeechSynthesizerMsgs* ptr) +{ + reply.return_helper = ptr->set_pitch(cmd.pitch); +} + +// get_pitch helper class implementation +bool ISpeechSynthesizerMsgs_get_pitch_helper::write(yarp::os::ConnectionWriter& connection) const +{ + return cmd.write(connection); +} + +bool ISpeechSynthesizerMsgs_get_pitch_helper::read(yarp::os::ConnectionReader& connection) +{ + return reply.read(connection); +} + +bool ISpeechSynthesizerMsgs_get_pitch_helper::Command::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(s_cmd_len)) { + return false; + } + return write(writer); +} + +bool ISpeechSynthesizerMsgs_get_pitch_helper::Command::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListHeader()) { + reader.fail(); + return false; + } + return read(reader); +} + +bool ISpeechSynthesizerMsgs_get_pitch_helper::Command::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writeTag(writer)) { + return false; + } + if (!writeArgs(writer)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_pitch_helper::Command::writeTag(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeTag(s_tag, 1, s_tag_len)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_pitch_helper::Command::writeArgs(const yarp::os::idl::WireWriter& writer [[maybe_unused]]) const +{ + return true; +} + +bool ISpeechSynthesizerMsgs_get_pitch_helper::Command::read(yarp::os::idl::WireReader& reader) +{ + if (!readTag(reader)) { + return false; + } + if (!readArgs(reader)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_pitch_helper::Command::readTag(yarp::os::idl::WireReader& reader) +{ + std::string tag = reader.readTag(s_tag_len); + if (reader.isError()) { + return false; + } + if (tag != s_tag) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_pitch_helper::Command::readArgs(yarp::os::idl::WireReader& reader) +{ + if (!reader.noMore()) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_pitch_helper::Reply::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + return write(writer); +} + +bool ISpeechSynthesizerMsgs_get_pitch_helper::Reply::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + return read(reader); +} + +bool ISpeechSynthesizerMsgs_get_pitch_helper::Reply::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.isNull()) { + if (!writer.writeListHeader(s_reply_len)) { + return false; + } + if (!writer.write(return_helper)) { + return false; + } + } + return true; +} + +bool ISpeechSynthesizerMsgs_get_pitch_helper::Reply::read(yarp::os::idl::WireReader& reader) +{ + if (!reader.readListReturn()) { + return false; + } + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.read(return_helper)) { + reader.fail(); + return false; + } + return true; +} + +void ISpeechSynthesizerMsgs_get_pitch_helper::call(ISpeechSynthesizerMsgs* ptr) +{ + reply.return_helper = ptr->get_pitch(); +} + +// synthesize helper class implementation +ISpeechSynthesizerMsgs_synthesize_helper::ISpeechSynthesizerMsgs_synthesize_helper(const std::string& text) : + cmd{text} +{ +} + +bool ISpeechSynthesizerMsgs_synthesize_helper::write(yarp::os::ConnectionWriter& connection) const +{ + return cmd.write(connection); +} + +bool ISpeechSynthesizerMsgs_synthesize_helper::read(yarp::os::ConnectionReader& connection) +{ + return reply.read(connection); +} + +ISpeechSynthesizerMsgs_synthesize_helper::Command::Command(const std::string& text) : + text{text} +{ +} + +bool ISpeechSynthesizerMsgs_synthesize_helper::Command::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(s_cmd_len)) { + return false; + } + return write(writer); +} + +bool ISpeechSynthesizerMsgs_synthesize_helper::Command::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListHeader()) { + reader.fail(); + return false; + } + return read(reader); +} + +bool ISpeechSynthesizerMsgs_synthesize_helper::Command::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writeTag(writer)) { + return false; + } + if (!writeArgs(writer)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_synthesize_helper::Command::writeTag(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeTag(s_tag, 1, s_tag_len)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_synthesize_helper::Command::writeArgs(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeString(text)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_synthesize_helper::Command::read(yarp::os::idl::WireReader& reader) +{ + if (!readTag(reader)) { + return false; + } + if (!readArgs(reader)) { + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_synthesize_helper::Command::readTag(yarp::os::idl::WireReader& reader) +{ + std::string tag = reader.readTag(s_tag_len); + if (reader.isError()) { + return false; + } + if (tag != s_tag) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_synthesize_helper::Command::readArgs(yarp::os::idl::WireReader& reader) +{ + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readString(text)) { + reader.fail(); + return false; + } + if (!reader.noMore()) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechSynthesizerMsgs_synthesize_helper::Reply::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + return write(writer); +} + +bool ISpeechSynthesizerMsgs_synthesize_helper::Reply::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + return read(reader); +} + +bool ISpeechSynthesizerMsgs_synthesize_helper::Reply::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.isNull()) { + if (!writer.writeListHeader(s_reply_len)) { + return false; + } + if (!writer.write(return_helper)) { + return false; + } + } + return true; +} + +bool ISpeechSynthesizerMsgs_synthesize_helper::Reply::read(yarp::os::idl::WireReader& reader) +{ + if (!reader.readListReturn()) { + return false; + } + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.read(return_helper)) { + reader.fail(); + return false; + } + return true; +} + +void ISpeechSynthesizerMsgs_synthesize_helper::call(ISpeechSynthesizerMsgs* ptr) +{ + reply.return_helper = ptr->synthesize(cmd.text); +} + +// Constructor +ISpeechSynthesizerMsgs::ISpeechSynthesizerMsgs() +{ + yarp().setOwner(*this); +} + +bool ISpeechSynthesizerMsgs::set_language(const std::string& language) +{ + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", ISpeechSynthesizerMsgs_set_language_helper::s_prototype); + } + ISpeechSynthesizerMsgs_set_language_helper helper{language}; + bool ok = yarp().write(helper, helper); + return ok ? helper.reply.return_helper : bool{}; +} + +return_get_language ISpeechSynthesizerMsgs::get_language() +{ + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", ISpeechSynthesizerMsgs_get_language_helper::s_prototype); + } + ISpeechSynthesizerMsgs_get_language_helper helper{}; + bool ok = yarp().write(helper, helper); + return ok ? helper.reply.return_helper : return_get_language{}; +} + +bool ISpeechSynthesizerMsgs::set_voice(const std::string& language) +{ + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", ISpeechSynthesizerMsgs_set_voice_helper::s_prototype); + } + ISpeechSynthesizerMsgs_set_voice_helper helper{language}; + bool ok = yarp().write(helper, helper); + return ok ? helper.reply.return_helper : bool{}; +} + +return_get_voice ISpeechSynthesizerMsgs::get_voice() +{ + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", ISpeechSynthesizerMsgs_get_voice_helper::s_prototype); + } + ISpeechSynthesizerMsgs_get_voice_helper helper{}; + bool ok = yarp().write(helper, helper); + return ok ? helper.reply.return_helper : return_get_voice{}; +} + +bool ISpeechSynthesizerMsgs::set_speed(const double speed) +{ + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", ISpeechSynthesizerMsgs_set_speed_helper::s_prototype); + } + ISpeechSynthesizerMsgs_set_speed_helper helper{speed}; + bool ok = yarp().write(helper, helper); + return ok ? helper.reply.return_helper : bool{}; +} + +return_get_speed ISpeechSynthesizerMsgs::get_speed() +{ + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", ISpeechSynthesizerMsgs_get_speed_helper::s_prototype); + } + ISpeechSynthesizerMsgs_get_speed_helper helper{}; + bool ok = yarp().write(helper, helper); + return ok ? helper.reply.return_helper : return_get_speed{}; +} + +bool ISpeechSynthesizerMsgs::set_pitch(const double pitch) +{ + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", ISpeechSynthesizerMsgs_set_pitch_helper::s_prototype); + } + ISpeechSynthesizerMsgs_set_pitch_helper helper{pitch}; + bool ok = yarp().write(helper, helper); + return ok ? helper.reply.return_helper : bool{}; +} + +return_get_pitch ISpeechSynthesizerMsgs::get_pitch() +{ + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", ISpeechSynthesizerMsgs_get_pitch_helper::s_prototype); + } + ISpeechSynthesizerMsgs_get_pitch_helper helper{}; + bool ok = yarp().write(helper, helper); + return ok ? helper.reply.return_helper : return_get_pitch{}; +} + +return_synthesize ISpeechSynthesizerMsgs::synthesize(const std::string& text) +{ + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", ISpeechSynthesizerMsgs_synthesize_helper::s_prototype); + } + ISpeechSynthesizerMsgs_synthesize_helper helper{text}; + bool ok = yarp().write(helper, helper); + return ok ? helper.reply.return_helper : return_synthesize{}; +} + +// help method +std::vector ISpeechSynthesizerMsgs::help(const std::string& functionName) +{ + bool showAll = (functionName == "--all"); + std::vector helpString; + if (showAll) { + helpString.emplace_back("*** Available commands:"); + helpString.emplace_back(ISpeechSynthesizerMsgs_set_language_helper::s_tag); + helpString.emplace_back(ISpeechSynthesizerMsgs_get_language_helper::s_tag); + helpString.emplace_back(ISpeechSynthesizerMsgs_set_voice_helper::s_tag); + helpString.emplace_back(ISpeechSynthesizerMsgs_get_voice_helper::s_tag); + helpString.emplace_back(ISpeechSynthesizerMsgs_set_speed_helper::s_tag); + helpString.emplace_back(ISpeechSynthesizerMsgs_get_speed_helper::s_tag); + helpString.emplace_back(ISpeechSynthesizerMsgs_set_pitch_helper::s_tag); + helpString.emplace_back(ISpeechSynthesizerMsgs_get_pitch_helper::s_tag); + helpString.emplace_back(ISpeechSynthesizerMsgs_synthesize_helper::s_tag); + helpString.emplace_back("help"); + } else { + if (functionName == ISpeechSynthesizerMsgs_set_language_helper::s_tag) { + helpString.emplace_back(ISpeechSynthesizerMsgs_set_language_helper::s_prototype); + } + if (functionName == ISpeechSynthesizerMsgs_get_language_helper::s_tag) { + helpString.emplace_back(ISpeechSynthesizerMsgs_get_language_helper::s_prototype); + } + if (functionName == ISpeechSynthesizerMsgs_set_voice_helper::s_tag) { + helpString.emplace_back(ISpeechSynthesizerMsgs_set_voice_helper::s_prototype); + } + if (functionName == ISpeechSynthesizerMsgs_get_voice_helper::s_tag) { + helpString.emplace_back(ISpeechSynthesizerMsgs_get_voice_helper::s_prototype); + } + if (functionName == ISpeechSynthesizerMsgs_set_speed_helper::s_tag) { + helpString.emplace_back(ISpeechSynthesizerMsgs_set_speed_helper::s_prototype); + } + if (functionName == ISpeechSynthesizerMsgs_get_speed_helper::s_tag) { + helpString.emplace_back(ISpeechSynthesizerMsgs_get_speed_helper::s_prototype); + } + if (functionName == ISpeechSynthesizerMsgs_set_pitch_helper::s_tag) { + helpString.emplace_back(ISpeechSynthesizerMsgs_set_pitch_helper::s_prototype); + } + if (functionName == ISpeechSynthesizerMsgs_get_pitch_helper::s_tag) { + helpString.emplace_back(ISpeechSynthesizerMsgs_get_pitch_helper::s_prototype); + } + if (functionName == ISpeechSynthesizerMsgs_synthesize_helper::s_tag) { + helpString.emplace_back(ISpeechSynthesizerMsgs_synthesize_helper::s_prototype); + } + if (functionName == "help") { + helpString.emplace_back("std::vector help(const std::string& functionName = \"--all\")"); + helpString.emplace_back("Return list of available commands, or help message for a specific function"); + helpString.emplace_back("@param functionName name of command for which to get a detailed description. If none or '--all' is provided, print list of available commands"); + helpString.emplace_back("@return list of strings (one string per line)"); + } + } + if (helpString.empty()) { + helpString.emplace_back("Command not found"); + } + return helpString; +} + +// read from ConnectionReader +bool ISpeechSynthesizerMsgs::read(yarp::os::ConnectionReader& connection) +{ + constexpr size_t max_tag_len = 2; + size_t tag_len = 1; + + yarp::os::idl::WireReader reader(connection); + reader.expectAccept(); + if (!reader.readListHeader()) { + reader.fail(); + return false; + } + + std::string tag = reader.readTag(1); + bool direct = (tag == "__direct__"); + if (direct) { + tag = reader.readTag(1); + } + while (tag_len <= max_tag_len && !reader.isError()) { + if (tag == ISpeechSynthesizerMsgs_set_language_helper::s_tag) { + ISpeechSynthesizerMsgs_set_language_helper helper; + if (!helper.cmd.readArgs(reader)) { + return false; + } + + helper.call(this); + + yarp::os::idl::WireWriter writer(reader); + if (!helper.reply.write(writer)) { + return false; + } + reader.accept(); + return true; + } + if (tag == ISpeechSynthesizerMsgs_get_language_helper::s_tag) { + ISpeechSynthesizerMsgs_get_language_helper helper; + if (!helper.cmd.readArgs(reader)) { + return false; + } + + helper.call(this); + + yarp::os::idl::WireWriter writer(reader); + if (!helper.reply.write(writer)) { + return false; + } + reader.accept(); + return true; + } + if (tag == ISpeechSynthesizerMsgs_set_voice_helper::s_tag) { + ISpeechSynthesizerMsgs_set_voice_helper helper; + if (!helper.cmd.readArgs(reader)) { + return false; + } + + helper.call(this); + + yarp::os::idl::WireWriter writer(reader); + if (!helper.reply.write(writer)) { + return false; + } + reader.accept(); + return true; + } + if (tag == ISpeechSynthesizerMsgs_get_voice_helper::s_tag) { + ISpeechSynthesizerMsgs_get_voice_helper helper; + if (!helper.cmd.readArgs(reader)) { + return false; + } + + helper.call(this); + + yarp::os::idl::WireWriter writer(reader); + if (!helper.reply.write(writer)) { + return false; + } + reader.accept(); + return true; + } + if (tag == ISpeechSynthesizerMsgs_set_speed_helper::s_tag) { + ISpeechSynthesizerMsgs_set_speed_helper helper; + if (!helper.cmd.readArgs(reader)) { + return false; + } + + helper.call(this); + + yarp::os::idl::WireWriter writer(reader); + if (!helper.reply.write(writer)) { + return false; + } + reader.accept(); + return true; + } + if (tag == ISpeechSynthesizerMsgs_get_speed_helper::s_tag) { + ISpeechSynthesizerMsgs_get_speed_helper helper; + if (!helper.cmd.readArgs(reader)) { + return false; + } + + helper.call(this); + + yarp::os::idl::WireWriter writer(reader); + if (!helper.reply.write(writer)) { + return false; + } + reader.accept(); + return true; + } + if (tag == ISpeechSynthesizerMsgs_set_pitch_helper::s_tag) { + ISpeechSynthesizerMsgs_set_pitch_helper helper; + if (!helper.cmd.readArgs(reader)) { + return false; + } + + helper.call(this); + + yarp::os::idl::WireWriter writer(reader); + if (!helper.reply.write(writer)) { + return false; + } + reader.accept(); + return true; + } + if (tag == ISpeechSynthesizerMsgs_get_pitch_helper::s_tag) { + ISpeechSynthesizerMsgs_get_pitch_helper helper; + if (!helper.cmd.readArgs(reader)) { + return false; + } + + helper.call(this); + + yarp::os::idl::WireWriter writer(reader); + if (!helper.reply.write(writer)) { + return false; + } + reader.accept(); + return true; + } + if (tag == ISpeechSynthesizerMsgs_synthesize_helper::s_tag) { + ISpeechSynthesizerMsgs_synthesize_helper helper; + if (!helper.cmd.readArgs(reader)) { + return false; + } + + helper.call(this); + + yarp::os::idl::WireWriter writer(reader); + if (!helper.reply.write(writer)) { + return false; + } + reader.accept(); + return true; + } + if (tag == "help") { + std::string functionName; + if (!reader.readString(functionName)) { + functionName = "--all"; + } + auto help_strings = help(functionName); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(2)) { + return false; + } + if (!writer.writeTag("many", 1, 0)) { + return false; + } + if (!writer.writeListBegin(0, help_strings.size())) { + return false; + } + for (const auto& help_string : help_strings) { + if (!writer.writeString(help_string)) { + return false; + } + } + if (!writer.writeListEnd()) { + return false; + } + } + reader.accept(); + return true; + } + if (reader.noMore()) { + reader.fail(); + return false; + } + std::string next_tag = reader.readTag(1); + if (next_tag.empty()) { + break; + } + tag.append("_").append(next_tag); + tag_len = std::count(tag.begin(), tag.end(), '_') + 1; + } + return false; +} diff --git a/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/ISpeechSynthesizerMsgs.h b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/ISpeechSynthesizerMsgs.h new file mode 100644 index 0000000000..1c618910b1 --- /dev/null +++ b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/ISpeechSynthesizerMsgs.h @@ -0,0 +1,54 @@ +/* + * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +// Autogenerated by Thrift Compiler (0.14.1-yarped) +// +// This is an automatically generated file. +// It could get re-generated if the ALLOW_IDL_GENERATION flag is on. + +#ifndef YARP_THRIFT_GENERATOR_SERVICE_ISPEECHSYNTHESIZERMSGS_H +#define YARP_THRIFT_GENERATOR_SERVICE_ISPEECHSYNTHESIZERMSGS_H + +#include +#include +#include +#include +#include +#include +#include + +class ISpeechSynthesizerMsgs : + public yarp::os::Wire +{ +public: + // Constructor + ISpeechSynthesizerMsgs(); + + virtual bool set_language(const std::string& language); + + virtual return_get_language get_language(); + + virtual bool set_voice(const std::string& language); + + virtual return_get_voice get_voice(); + + virtual bool set_speed(const double speed); + + virtual return_get_speed get_speed(); + + virtual bool set_pitch(const double pitch); + + virtual return_get_pitch get_pitch(); + + virtual return_synthesize synthesize(const std::string& text); + + // help method + virtual std::vector help(const std::string& functionName = "--all"); + + // read from ConnectionReader + bool read(yarp::os::ConnectionReader& connection) override; +}; + +#endif // YARP_THRIFT_GENERATOR_SERVICE_ISPEECHSYNTHESIZERMSGS_H diff --git a/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/ISpeechSynthesizerMsgs_index.txt b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/ISpeechSynthesizerMsgs_index.txt new file mode 100644 index 0000000000..0af6262894 --- /dev/null +++ b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/ISpeechSynthesizerMsgs_index.txt @@ -0,0 +1,12 @@ +return_get_language.h +return_get_language.cpp +return_get_voice.h +return_get_voice.cpp +return_get_speed.h +return_get_speed.cpp +return_get_pitch.h +return_get_pitch.cpp +return_synthesize.h +return_synthesize.cpp +ISpeechSynthesizerMsgs.h +ISpeechSynthesizerMsgs.cpp diff --git a/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_language.cpp b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_language.cpp new file mode 100644 index 0000000000..bbd24b5101 --- /dev/null +++ b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_language.cpp @@ -0,0 +1,168 @@ +/* + * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +// Autogenerated by Thrift Compiler (0.14.1-yarped) +// +// This is an automatically generated file. +// It could get re-generated if the ALLOW_IDL_GENERATION flag is on. + +#include + +// Constructor with field values +return_get_language::return_get_language(const bool ret, + const std::string& language) : + WirePortable(), + ret(ret), + language(language) +{ +} + +// Read structure on a Wire +bool return_get_language::read(yarp::os::idl::WireReader& reader) +{ + if (!read_ret(reader)) { + return false; + } + if (!read_language(reader)) { + return false; + } + if (reader.isError()) { + return false; + } + return true; +} + +// Read structure on a Connection +bool return_get_language::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListHeader(2)) { + return false; + } + if (!read(reader)) { + return false; + } + return true; +} + +// Write structure on a Wire +bool return_get_language::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!write_ret(writer)) { + return false; + } + if (!write_language(writer)) { + return false; + } + if (writer.isError()) { + return false; + } + return true; +} + +// Write structure on a Connection +bool return_get_language::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(2)) { + return false; + } + if (!write(writer)) { + return false; + } + return true; +} + +// Convert to a printable string +std::string return_get_language::toString() const +{ + yarp::os::Bottle b; + if (!yarp::os::Portable::copyPortable(*this, b)) { + return {}; + } + return b.toString(); +} + +// read ret field +bool return_get_language::read_ret(yarp::os::idl::WireReader& reader) +{ + if (!reader.readBool(ret)) { + ret = false; + } + return true; +} + +// write ret field +bool return_get_language::write_ret(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeBool(ret)) { + return false; + } + return true; +} + +// read (nested) ret field +bool return_get_language::nested_read_ret(yarp::os::idl::WireReader& reader) +{ + if (!reader.readBool(ret)) { + ret = false; + } + return true; +} + +// write (nested) ret field +bool return_get_language::nested_write_ret(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeBool(ret)) { + return false; + } + return true; +} + +// read language field +bool return_get_language::read_language(yarp::os::idl::WireReader& reader) +{ + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readString(language)) { + reader.fail(); + return false; + } + return true; +} + +// write language field +bool return_get_language::write_language(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeString(language)) { + return false; + } + return true; +} + +// read (nested) language field +bool return_get_language::nested_read_language(yarp::os::idl::WireReader& reader) +{ + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readString(language)) { + reader.fail(); + return false; + } + return true; +} + +// write (nested) language field +bool return_get_language::nested_write_language(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeString(language)) { + return false; + } + return true; +} diff --git a/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_language.h b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_language.h new file mode 100644 index 0000000000..a00bb6dbf6 --- /dev/null +++ b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_language.h @@ -0,0 +1,64 @@ +/* + * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +// Autogenerated by Thrift Compiler (0.14.1-yarped) +// +// This is an automatically generated file. +// It could get re-generated if the ALLOW_IDL_GENERATION flag is on. + +#ifndef YARP_THRIFT_GENERATOR_STRUCT_RETURN_GET_LANGUAGE_H +#define YARP_THRIFT_GENERATOR_STRUCT_RETURN_GET_LANGUAGE_H + +#include +#include + +class return_get_language : + public yarp::os::idl::WirePortable +{ +public: + // Fields + bool ret{false}; + std::string language{}; + + // Default constructor + return_get_language() = default; + + // Constructor with field values + return_get_language(const bool ret, + const std::string& language); + + // Read structure on a Wire + bool read(yarp::os::idl::WireReader& reader) override; + + // Read structure on a Connection + bool read(yarp::os::ConnectionReader& connection) override; + + // Write structure on a Wire + bool write(const yarp::os::idl::WireWriter& writer) const override; + + // Write structure on a Connection + bool write(yarp::os::ConnectionWriter& connection) const override; + + // Convert to a printable string + std::string toString() const; + + // If you want to serialize this class without nesting, use this helper + typedef yarp::os::idl::Unwrapped unwrapped; + +private: + // read/write ret field + bool read_ret(yarp::os::idl::WireReader& reader); + bool write_ret(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_ret(yarp::os::idl::WireReader& reader); + bool nested_write_ret(const yarp::os::idl::WireWriter& writer) const; + + // read/write language field + bool read_language(yarp::os::idl::WireReader& reader); + bool write_language(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_language(yarp::os::idl::WireReader& reader); + bool nested_write_language(const yarp::os::idl::WireWriter& writer) const; +}; + +#endif // YARP_THRIFT_GENERATOR_STRUCT_RETURN_GET_LANGUAGE_H diff --git a/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_pitch.cpp b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_pitch.cpp new file mode 100644 index 0000000000..5c98ae961a --- /dev/null +++ b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_pitch.cpp @@ -0,0 +1,168 @@ +/* + * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +// Autogenerated by Thrift Compiler (0.14.1-yarped) +// +// This is an automatically generated file. +// It could get re-generated if the ALLOW_IDL_GENERATION flag is on. + +#include + +// Constructor with field values +return_get_pitch::return_get_pitch(const bool ret, + const double pitch) : + WirePortable(), + ret(ret), + pitch(pitch) +{ +} + +// Read structure on a Wire +bool return_get_pitch::read(yarp::os::idl::WireReader& reader) +{ + if (!read_ret(reader)) { + return false; + } + if (!read_pitch(reader)) { + return false; + } + if (reader.isError()) { + return false; + } + return true; +} + +// Read structure on a Connection +bool return_get_pitch::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListHeader(2)) { + return false; + } + if (!read(reader)) { + return false; + } + return true; +} + +// Write structure on a Wire +bool return_get_pitch::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!write_ret(writer)) { + return false; + } + if (!write_pitch(writer)) { + return false; + } + if (writer.isError()) { + return false; + } + return true; +} + +// Write structure on a Connection +bool return_get_pitch::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(2)) { + return false; + } + if (!write(writer)) { + return false; + } + return true; +} + +// Convert to a printable string +std::string return_get_pitch::toString() const +{ + yarp::os::Bottle b; + if (!yarp::os::Portable::copyPortable(*this, b)) { + return {}; + } + return b.toString(); +} + +// read ret field +bool return_get_pitch::read_ret(yarp::os::idl::WireReader& reader) +{ + if (!reader.readBool(ret)) { + ret = false; + } + return true; +} + +// write ret field +bool return_get_pitch::write_ret(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeBool(ret)) { + return false; + } + return true; +} + +// read (nested) ret field +bool return_get_pitch::nested_read_ret(yarp::os::idl::WireReader& reader) +{ + if (!reader.readBool(ret)) { + ret = false; + } + return true; +} + +// write (nested) ret field +bool return_get_pitch::nested_write_ret(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeBool(ret)) { + return false; + } + return true; +} + +// read pitch field +bool return_get_pitch::read_pitch(yarp::os::idl::WireReader& reader) +{ + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readFloat64(pitch)) { + reader.fail(); + return false; + } + return true; +} + +// write pitch field +bool return_get_pitch::write_pitch(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeFloat64(pitch)) { + return false; + } + return true; +} + +// read (nested) pitch field +bool return_get_pitch::nested_read_pitch(yarp::os::idl::WireReader& reader) +{ + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readFloat64(pitch)) { + reader.fail(); + return false; + } + return true; +} + +// write (nested) pitch field +bool return_get_pitch::nested_write_pitch(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeFloat64(pitch)) { + return false; + } + return true; +} diff --git a/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_pitch.h b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_pitch.h new file mode 100644 index 0000000000..6f552abca3 --- /dev/null +++ b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_pitch.h @@ -0,0 +1,64 @@ +/* + * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +// Autogenerated by Thrift Compiler (0.14.1-yarped) +// +// This is an automatically generated file. +// It could get re-generated if the ALLOW_IDL_GENERATION flag is on. + +#ifndef YARP_THRIFT_GENERATOR_STRUCT_RETURN_GET_PITCH_H +#define YARP_THRIFT_GENERATOR_STRUCT_RETURN_GET_PITCH_H + +#include +#include + +class return_get_pitch : + public yarp::os::idl::WirePortable +{ +public: + // Fields + bool ret{false}; + double pitch{0.0}; + + // Default constructor + return_get_pitch() = default; + + // Constructor with field values + return_get_pitch(const bool ret, + const double pitch); + + // Read structure on a Wire + bool read(yarp::os::idl::WireReader& reader) override; + + // Read structure on a Connection + bool read(yarp::os::ConnectionReader& connection) override; + + // Write structure on a Wire + bool write(const yarp::os::idl::WireWriter& writer) const override; + + // Write structure on a Connection + bool write(yarp::os::ConnectionWriter& connection) const override; + + // Convert to a printable string + std::string toString() const; + + // If you want to serialize this class without nesting, use this helper + typedef yarp::os::idl::Unwrapped unwrapped; + +private: + // read/write ret field + bool read_ret(yarp::os::idl::WireReader& reader); + bool write_ret(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_ret(yarp::os::idl::WireReader& reader); + bool nested_write_ret(const yarp::os::idl::WireWriter& writer) const; + + // read/write pitch field + bool read_pitch(yarp::os::idl::WireReader& reader); + bool write_pitch(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_pitch(yarp::os::idl::WireReader& reader); + bool nested_write_pitch(const yarp::os::idl::WireWriter& writer) const; +}; + +#endif // YARP_THRIFT_GENERATOR_STRUCT_RETURN_GET_PITCH_H diff --git a/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_speed.cpp b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_speed.cpp new file mode 100644 index 0000000000..b725e25bee --- /dev/null +++ b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_speed.cpp @@ -0,0 +1,168 @@ +/* + * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +// Autogenerated by Thrift Compiler (0.14.1-yarped) +// +// This is an automatically generated file. +// It could get re-generated if the ALLOW_IDL_GENERATION flag is on. + +#include + +// Constructor with field values +return_get_speed::return_get_speed(const bool ret, + const double speed) : + WirePortable(), + ret(ret), + speed(speed) +{ +} + +// Read structure on a Wire +bool return_get_speed::read(yarp::os::idl::WireReader& reader) +{ + if (!read_ret(reader)) { + return false; + } + if (!read_speed(reader)) { + return false; + } + if (reader.isError()) { + return false; + } + return true; +} + +// Read structure on a Connection +bool return_get_speed::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListHeader(2)) { + return false; + } + if (!read(reader)) { + return false; + } + return true; +} + +// Write structure on a Wire +bool return_get_speed::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!write_ret(writer)) { + return false; + } + if (!write_speed(writer)) { + return false; + } + if (writer.isError()) { + return false; + } + return true; +} + +// Write structure on a Connection +bool return_get_speed::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(2)) { + return false; + } + if (!write(writer)) { + return false; + } + return true; +} + +// Convert to a printable string +std::string return_get_speed::toString() const +{ + yarp::os::Bottle b; + if (!yarp::os::Portable::copyPortable(*this, b)) { + return {}; + } + return b.toString(); +} + +// read ret field +bool return_get_speed::read_ret(yarp::os::idl::WireReader& reader) +{ + if (!reader.readBool(ret)) { + ret = false; + } + return true; +} + +// write ret field +bool return_get_speed::write_ret(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeBool(ret)) { + return false; + } + return true; +} + +// read (nested) ret field +bool return_get_speed::nested_read_ret(yarp::os::idl::WireReader& reader) +{ + if (!reader.readBool(ret)) { + ret = false; + } + return true; +} + +// write (nested) ret field +bool return_get_speed::nested_write_ret(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeBool(ret)) { + return false; + } + return true; +} + +// read speed field +bool return_get_speed::read_speed(yarp::os::idl::WireReader& reader) +{ + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readFloat64(speed)) { + reader.fail(); + return false; + } + return true; +} + +// write speed field +bool return_get_speed::write_speed(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeFloat64(speed)) { + return false; + } + return true; +} + +// read (nested) speed field +bool return_get_speed::nested_read_speed(yarp::os::idl::WireReader& reader) +{ + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readFloat64(speed)) { + reader.fail(); + return false; + } + return true; +} + +// write (nested) speed field +bool return_get_speed::nested_write_speed(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeFloat64(speed)) { + return false; + } + return true; +} diff --git a/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_speed.h b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_speed.h new file mode 100644 index 0000000000..71c8e268f8 --- /dev/null +++ b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_speed.h @@ -0,0 +1,64 @@ +/* + * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +// Autogenerated by Thrift Compiler (0.14.1-yarped) +// +// This is an automatically generated file. +// It could get re-generated if the ALLOW_IDL_GENERATION flag is on. + +#ifndef YARP_THRIFT_GENERATOR_STRUCT_RETURN_GET_SPEED_H +#define YARP_THRIFT_GENERATOR_STRUCT_RETURN_GET_SPEED_H + +#include +#include + +class return_get_speed : + public yarp::os::idl::WirePortable +{ +public: + // Fields + bool ret{false}; + double speed{0.0}; + + // Default constructor + return_get_speed() = default; + + // Constructor with field values + return_get_speed(const bool ret, + const double speed); + + // Read structure on a Wire + bool read(yarp::os::idl::WireReader& reader) override; + + // Read structure on a Connection + bool read(yarp::os::ConnectionReader& connection) override; + + // Write structure on a Wire + bool write(const yarp::os::idl::WireWriter& writer) const override; + + // Write structure on a Connection + bool write(yarp::os::ConnectionWriter& connection) const override; + + // Convert to a printable string + std::string toString() const; + + // If you want to serialize this class without nesting, use this helper + typedef yarp::os::idl::Unwrapped unwrapped; + +private: + // read/write ret field + bool read_ret(yarp::os::idl::WireReader& reader); + bool write_ret(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_ret(yarp::os::idl::WireReader& reader); + bool nested_write_ret(const yarp::os::idl::WireWriter& writer) const; + + // read/write speed field + bool read_speed(yarp::os::idl::WireReader& reader); + bool write_speed(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_speed(yarp::os::idl::WireReader& reader); + bool nested_write_speed(const yarp::os::idl::WireWriter& writer) const; +}; + +#endif // YARP_THRIFT_GENERATOR_STRUCT_RETURN_GET_SPEED_H diff --git a/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_voice.cpp b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_voice.cpp new file mode 100644 index 0000000000..4b4323b515 --- /dev/null +++ b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_voice.cpp @@ -0,0 +1,168 @@ +/* + * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +// Autogenerated by Thrift Compiler (0.14.1-yarped) +// +// This is an automatically generated file. +// It could get re-generated if the ALLOW_IDL_GENERATION flag is on. + +#include + +// Constructor with field values +return_get_voice::return_get_voice(const bool ret, + const std::string& voice) : + WirePortable(), + ret(ret), + voice(voice) +{ +} + +// Read structure on a Wire +bool return_get_voice::read(yarp::os::idl::WireReader& reader) +{ + if (!read_ret(reader)) { + return false; + } + if (!read_voice(reader)) { + return false; + } + if (reader.isError()) { + return false; + } + return true; +} + +// Read structure on a Connection +bool return_get_voice::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListHeader(2)) { + return false; + } + if (!read(reader)) { + return false; + } + return true; +} + +// Write structure on a Wire +bool return_get_voice::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!write_ret(writer)) { + return false; + } + if (!write_voice(writer)) { + return false; + } + if (writer.isError()) { + return false; + } + return true; +} + +// Write structure on a Connection +bool return_get_voice::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(2)) { + return false; + } + if (!write(writer)) { + return false; + } + return true; +} + +// Convert to a printable string +std::string return_get_voice::toString() const +{ + yarp::os::Bottle b; + if (!yarp::os::Portable::copyPortable(*this, b)) { + return {}; + } + return b.toString(); +} + +// read ret field +bool return_get_voice::read_ret(yarp::os::idl::WireReader& reader) +{ + if (!reader.readBool(ret)) { + ret = false; + } + return true; +} + +// write ret field +bool return_get_voice::write_ret(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeBool(ret)) { + return false; + } + return true; +} + +// read (nested) ret field +bool return_get_voice::nested_read_ret(yarp::os::idl::WireReader& reader) +{ + if (!reader.readBool(ret)) { + ret = false; + } + return true; +} + +// write (nested) ret field +bool return_get_voice::nested_write_ret(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeBool(ret)) { + return false; + } + return true; +} + +// read voice field +bool return_get_voice::read_voice(yarp::os::idl::WireReader& reader) +{ + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readString(voice)) { + reader.fail(); + return false; + } + return true; +} + +// write voice field +bool return_get_voice::write_voice(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeString(voice)) { + return false; + } + return true; +} + +// read (nested) voice field +bool return_get_voice::nested_read_voice(yarp::os::idl::WireReader& reader) +{ + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readString(voice)) { + reader.fail(); + return false; + } + return true; +} + +// write (nested) voice field +bool return_get_voice::nested_write_voice(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeString(voice)) { + return false; + } + return true; +} diff --git a/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_voice.h b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_voice.h new file mode 100644 index 0000000000..fb9ab5f7e4 --- /dev/null +++ b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_get_voice.h @@ -0,0 +1,64 @@ +/* + * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +// Autogenerated by Thrift Compiler (0.14.1-yarped) +// +// This is an automatically generated file. +// It could get re-generated if the ALLOW_IDL_GENERATION flag is on. + +#ifndef YARP_THRIFT_GENERATOR_STRUCT_RETURN_GET_VOICE_H +#define YARP_THRIFT_GENERATOR_STRUCT_RETURN_GET_VOICE_H + +#include +#include + +class return_get_voice : + public yarp::os::idl::WirePortable +{ +public: + // Fields + bool ret{false}; + std::string voice{}; + + // Default constructor + return_get_voice() = default; + + // Constructor with field values + return_get_voice(const bool ret, + const std::string& voice); + + // Read structure on a Wire + bool read(yarp::os::idl::WireReader& reader) override; + + // Read structure on a Connection + bool read(yarp::os::ConnectionReader& connection) override; + + // Write structure on a Wire + bool write(const yarp::os::idl::WireWriter& writer) const override; + + // Write structure on a Connection + bool write(yarp::os::ConnectionWriter& connection) const override; + + // Convert to a printable string + std::string toString() const; + + // If you want to serialize this class without nesting, use this helper + typedef yarp::os::idl::Unwrapped unwrapped; + +private: + // read/write ret field + bool read_ret(yarp::os::idl::WireReader& reader); + bool write_ret(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_ret(yarp::os::idl::WireReader& reader); + bool nested_write_ret(const yarp::os::idl::WireWriter& writer) const; + + // read/write voice field + bool read_voice(yarp::os::idl::WireReader& reader); + bool write_voice(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_voice(yarp::os::idl::WireReader& reader); + bool nested_write_voice(const yarp::os::idl::WireWriter& writer) const; +}; + +#endif // YARP_THRIFT_GENERATOR_STRUCT_RETURN_GET_VOICE_H diff --git a/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_synthesize.cpp b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_synthesize.cpp new file mode 100644 index 0000000000..b9989a09bf --- /dev/null +++ b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_synthesize.cpp @@ -0,0 +1,168 @@ +/* + * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +// Autogenerated by Thrift Compiler (0.14.1-yarped) +// +// This is an automatically generated file. +// It could get re-generated if the ALLOW_IDL_GENERATION flag is on. + +#include + +// Constructor with field values +return_synthesize::return_synthesize(const bool ret, + const yarp::sig::Sound& sound) : + WirePortable(), + ret(ret), + sound(sound) +{ +} + +// Read structure on a Wire +bool return_synthesize::read(yarp::os::idl::WireReader& reader) +{ + if (!read_ret(reader)) { + return false; + } + if (!nested_read_sound(reader)) { + return false; + } + if (reader.isError()) { + return false; + } + return true; +} + +// Read structure on a Connection +bool return_synthesize::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListHeader(2)) { + return false; + } + if (!read(reader)) { + return false; + } + return true; +} + +// Write structure on a Wire +bool return_synthesize::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!write_ret(writer)) { + return false; + } + if (!nested_write_sound(writer)) { + return false; + } + if (writer.isError()) { + return false; + } + return true; +} + +// Write structure on a Connection +bool return_synthesize::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(2)) { + return false; + } + if (!write(writer)) { + return false; + } + return true; +} + +// Convert to a printable string +std::string return_synthesize::toString() const +{ + yarp::os::Bottle b; + if (!yarp::os::Portable::copyPortable(*this, b)) { + return {}; + } + return b.toString(); +} + +// read ret field +bool return_synthesize::read_ret(yarp::os::idl::WireReader& reader) +{ + if (!reader.readBool(ret)) { + ret = false; + } + return true; +} + +// write ret field +bool return_synthesize::write_ret(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeBool(ret)) { + return false; + } + return true; +} + +// read (nested) ret field +bool return_synthesize::nested_read_ret(yarp::os::idl::WireReader& reader) +{ + if (!reader.readBool(ret)) { + ret = false; + } + return true; +} + +// write (nested) ret field +bool return_synthesize::nested_write_ret(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeBool(ret)) { + return false; + } + return true; +} + +// read sound field +bool return_synthesize::read_sound(yarp::os::idl::WireReader& reader) +{ + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.read(sound)) { + reader.fail(); + return false; + } + return true; +} + +// write sound field +bool return_synthesize::write_sound(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.write(sound)) { + return false; + } + return true; +} + +// read (nested) sound field +bool return_synthesize::nested_read_sound(yarp::os::idl::WireReader& reader) +{ + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readNested(sound)) { + reader.fail(); + return false; + } + return true; +} + +// write (nested) sound field +bool return_synthesize::nested_write_sound(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeNested(sound)) { + return false; + } + return true; +} diff --git a/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_synthesize.h b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_synthesize.h new file mode 100644 index 0000000000..7c847a55b5 --- /dev/null +++ b/src/devices/ISpeechSynthesizerMsgs/idl_generated_code/return_synthesize.h @@ -0,0 +1,65 @@ +/* + * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +// Autogenerated by Thrift Compiler (0.14.1-yarped) +// +// This is an automatically generated file. +// It could get re-generated if the ALLOW_IDL_GENERATION flag is on. + +#ifndef YARP_THRIFT_GENERATOR_STRUCT_RETURN_SYNTHESIZE_H +#define YARP_THRIFT_GENERATOR_STRUCT_RETURN_SYNTHESIZE_H + +#include +#include +#include + +class return_synthesize : + public yarp::os::idl::WirePortable +{ +public: + // Fields + bool ret{false}; + yarp::sig::Sound sound{}; + + // Default constructor + return_synthesize() = default; + + // Constructor with field values + return_synthesize(const bool ret, + const yarp::sig::Sound& sound); + + // Read structure on a Wire + bool read(yarp::os::idl::WireReader& reader) override; + + // Read structure on a Connection + bool read(yarp::os::ConnectionReader& connection) override; + + // Write structure on a Wire + bool write(const yarp::os::idl::WireWriter& writer) const override; + + // Write structure on a Connection + bool write(yarp::os::ConnectionWriter& connection) const override; + + // Convert to a printable string + std::string toString() const; + + // If you want to serialize this class without nesting, use this helper + typedef yarp::os::idl::Unwrapped unwrapped; + +private: + // read/write ret field + bool read_ret(yarp::os::idl::WireReader& reader); + bool write_ret(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_ret(yarp::os::idl::WireReader& reader); + bool nested_write_ret(const yarp::os::idl::WireWriter& writer) const; + + // read/write sound field + bool read_sound(yarp::os::idl::WireReader& reader); + bool write_sound(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_sound(yarp::os::idl::WireReader& reader); + bool nested_write_sound(const yarp::os::idl::WireWriter& writer) const; +}; + +#endif // YARP_THRIFT_GENERATOR_STRUCT_RETURN_SYNTHESIZE_H diff --git a/src/devices/ISpeechTranscriptionMsgs/CMakeLists.txt b/src/devices/ISpeechTranscriptionMsgs/CMakeLists.txt new file mode 100644 index 0000000000..c4ff799c52 --- /dev/null +++ b/src/devices/ISpeechTranscriptionMsgs/CMakeLists.txt @@ -0,0 +1,24 @@ +# SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) +# SPDX-License-Identifier: BSD-3-Clause + +if(NOT YARP_COMPILE_DEVICE_PLUGINS) + return() +endif() + +include(YarpChooseIDL) +yarp_choose_idl(ISPEECHTRANSCMSG_THRIFT ISpeechTranscriptionMsgs.thrift) + +add_library(ISpeechTranscriptionMsgs OBJECT) + +target_sources(ISpeechTranscriptionMsgs PRIVATE ${ISPEECHTRANSCMSG_THRIFT_GEN_FILES}) + +target_link_libraries(ISpeechTranscriptionMsgs + PRIVATE + YARP::YARP_dev + YARP::YARP_os + YARP::YARP_sig +) + +target_include_directories(ISpeechTranscriptionMsgs PUBLIC ${ISPEECHTRANSCMSG_THRIFT_BUILD_INTERFACE_INCLUDE_DIRS}) + +set_property(TARGET ISpeechTranscriptionMsgs PROPERTY FOLDER "Devices/Shared") diff --git a/src/devices/ISpeechTranscriptionMsgs/ISpeechTranscriptionMsgs.thrift b/src/devices/ISpeechTranscriptionMsgs/ISpeechTranscriptionMsgs.thrift new file mode 100644 index 0000000000..72b9920264 --- /dev/null +++ b/src/devices/ISpeechTranscriptionMsgs/ISpeechTranscriptionMsgs.thrift @@ -0,0 +1,28 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +struct yarp_sig_Sound { +} ( + yarp.name = "yarp::sig::Sound" + yarp.includefile = "yarp/sig/Sound.h" +) + +struct return_get_language { + 1: bool ret = false; + 2: string language; +} + +struct return_transcribe { + 1: bool ret = false; + 2: string transcription; + 3: double score; +} + +service ISpeechTranscriptionMsgs +{ + bool set_language (1:string language); + return_get_language get_language (); + return_transcribe transcribe (1:yarp_sig_Sound sound); +} diff --git a/src/devices/ISpeechTranscriptionMsgs/idl_generated_code/ISpeechTranscriptionMsgs.cpp b/src/devices/ISpeechTranscriptionMsgs/idl_generated_code/ISpeechTranscriptionMsgs.cpp new file mode 100644 index 0000000000..96582feffc --- /dev/null +++ b/src/devices/ISpeechTranscriptionMsgs/idl_generated_code/ISpeechTranscriptionMsgs.cpp @@ -0,0 +1,817 @@ +/* + * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +// Autogenerated by Thrift Compiler (0.14.1-yarped) +// +// This is an automatically generated file. +// It could get re-generated if the ALLOW_IDL_GENERATION flag is on. + +#include + +#include + +#include + +// set_language helper class declaration +class ISpeechTranscriptionMsgs_set_language_helper : + public yarp::os::Portable +{ +public: + ISpeechTranscriptionMsgs_set_language_helper() = default; + explicit ISpeechTranscriptionMsgs_set_language_helper(const std::string& language); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + class Command : + public yarp::os::idl::WirePortable + { + public: + Command() = default; + explicit Command(const std::string& language); + + ~Command() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool writeTag(const yarp::os::idl::WireWriter& writer) const; + bool writeArgs(const yarp::os::idl::WireWriter& writer) const; + + bool read(yarp::os::idl::WireReader& reader) override; + bool readTag(yarp::os::idl::WireReader& reader); + bool readArgs(yarp::os::idl::WireReader& reader); + + std::string language{}; + }; + + class Reply : + public yarp::os::idl::WirePortable + { + public: + Reply() = default; + ~Reply() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool read(yarp::os::idl::WireReader& reader) override; + + bool return_helper{false}; + }; + + using funcptr_t = bool (*)(const std::string&); + void call(ISpeechTranscriptionMsgs* ptr); + + Command cmd; + Reply reply; + + static constexpr const char* s_tag{"set_language"}; + static constexpr size_t s_tag_len{2}; + static constexpr size_t s_cmd_len{3}; + static constexpr size_t s_reply_len{1}; + static constexpr const char* s_prototype{"bool ISpeechTranscriptionMsgs::set_language(const std::string& language)"}; + static constexpr const char* s_help{""}; +}; + +// get_language helper class declaration +class ISpeechTranscriptionMsgs_get_language_helper : + public yarp::os::Portable +{ +public: + ISpeechTranscriptionMsgs_get_language_helper() = default; + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + class Command : + public yarp::os::idl::WirePortable + { + public: + Command() = default; + ~Command() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool writeTag(const yarp::os::idl::WireWriter& writer) const; + bool writeArgs(const yarp::os::idl::WireWriter& writer) const; + + bool read(yarp::os::idl::WireReader& reader) override; + bool readTag(yarp::os::idl::WireReader& reader); + bool readArgs(yarp::os::idl::WireReader& reader); + }; + + class Reply : + public yarp::os::idl::WirePortable + { + public: + Reply() = default; + ~Reply() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool read(yarp::os::idl::WireReader& reader) override; + + return_get_language return_helper{}; + }; + + using funcptr_t = return_get_language (*)(); + void call(ISpeechTranscriptionMsgs* ptr); + + Command cmd; + Reply reply; + + static constexpr const char* s_tag{"get_language"}; + static constexpr size_t s_tag_len{2}; + static constexpr size_t s_cmd_len{2}; + static constexpr size_t s_reply_len{2}; + static constexpr const char* s_prototype{"return_get_language ISpeechTranscriptionMsgs::get_language()"}; + static constexpr const char* s_help{""}; +}; + +// transcribe helper class declaration +class ISpeechTranscriptionMsgs_transcribe_helper : + public yarp::os::Portable +{ +public: + ISpeechTranscriptionMsgs_transcribe_helper() = default; + explicit ISpeechTranscriptionMsgs_transcribe_helper(const yarp::sig::Sound& sound); + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + class Command : + public yarp::os::idl::WirePortable + { + public: + Command() = default; + explicit Command(const yarp::sig::Sound& sound); + + ~Command() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool writeTag(const yarp::os::idl::WireWriter& writer) const; + bool writeArgs(const yarp::os::idl::WireWriter& writer) const; + + bool read(yarp::os::idl::WireReader& reader) override; + bool readTag(yarp::os::idl::WireReader& reader); + bool readArgs(yarp::os::idl::WireReader& reader); + + yarp::sig::Sound sound{}; + }; + + class Reply : + public yarp::os::idl::WirePortable + { + public: + Reply() = default; + ~Reply() override = default; + + bool write(yarp::os::ConnectionWriter& connection) const override; + bool read(yarp::os::ConnectionReader& connection) override; + + bool write(const yarp::os::idl::WireWriter& writer) const override; + bool read(yarp::os::idl::WireReader& reader) override; + + return_transcribe return_helper{}; + }; + + using funcptr_t = return_transcribe (*)(const yarp::sig::Sound&); + void call(ISpeechTranscriptionMsgs* ptr); + + Command cmd; + Reply reply; + + static constexpr const char* s_tag{"transcribe"}; + static constexpr size_t s_tag_len{1}; + static constexpr size_t s_cmd_len{2}; + static constexpr size_t s_reply_len{3}; + static constexpr const char* s_prototype{"return_transcribe ISpeechTranscriptionMsgs::transcribe(const yarp::sig::Sound& sound)"}; + static constexpr const char* s_help{""}; +}; + +// set_language helper class implementation +ISpeechTranscriptionMsgs_set_language_helper::ISpeechTranscriptionMsgs_set_language_helper(const std::string& language) : + cmd{language} +{ +} + +bool ISpeechTranscriptionMsgs_set_language_helper::write(yarp::os::ConnectionWriter& connection) const +{ + return cmd.write(connection); +} + +bool ISpeechTranscriptionMsgs_set_language_helper::read(yarp::os::ConnectionReader& connection) +{ + return reply.read(connection); +} + +ISpeechTranscriptionMsgs_set_language_helper::Command::Command(const std::string& language) : + language{language} +{ +} + +bool ISpeechTranscriptionMsgs_set_language_helper::Command::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(s_cmd_len)) { + return false; + } + return write(writer); +} + +bool ISpeechTranscriptionMsgs_set_language_helper::Command::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListHeader()) { + reader.fail(); + return false; + } + return read(reader); +} + +bool ISpeechTranscriptionMsgs_set_language_helper::Command::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writeTag(writer)) { + return false; + } + if (!writeArgs(writer)) { + return false; + } + return true; +} + +bool ISpeechTranscriptionMsgs_set_language_helper::Command::writeTag(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeTag(s_tag, 1, s_tag_len)) { + return false; + } + return true; +} + +bool ISpeechTranscriptionMsgs_set_language_helper::Command::writeArgs(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeString(language)) { + return false; + } + return true; +} + +bool ISpeechTranscriptionMsgs_set_language_helper::Command::read(yarp::os::idl::WireReader& reader) +{ + if (!readTag(reader)) { + return false; + } + if (!readArgs(reader)) { + return false; + } + return true; +} + +bool ISpeechTranscriptionMsgs_set_language_helper::Command::readTag(yarp::os::idl::WireReader& reader) +{ + std::string tag = reader.readTag(s_tag_len); + if (reader.isError()) { + return false; + } + if (tag != s_tag) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechTranscriptionMsgs_set_language_helper::Command::readArgs(yarp::os::idl::WireReader& reader) +{ + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readString(language)) { + reader.fail(); + return false; + } + if (!reader.noMore()) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechTranscriptionMsgs_set_language_helper::Reply::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + return write(writer); +} + +bool ISpeechTranscriptionMsgs_set_language_helper::Reply::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + return read(reader); +} + +bool ISpeechTranscriptionMsgs_set_language_helper::Reply::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.isNull()) { + if (!writer.writeListHeader(s_reply_len)) { + return false; + } + if (!writer.writeBool(return_helper)) { + return false; + } + } + return true; +} + +bool ISpeechTranscriptionMsgs_set_language_helper::Reply::read(yarp::os::idl::WireReader& reader) +{ + if (!reader.readListReturn()) { + return false; + } + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readBool(return_helper)) { + reader.fail(); + return false; + } + return true; +} + +void ISpeechTranscriptionMsgs_set_language_helper::call(ISpeechTranscriptionMsgs* ptr) +{ + reply.return_helper = ptr->set_language(cmd.language); +} + +// get_language helper class implementation +bool ISpeechTranscriptionMsgs_get_language_helper::write(yarp::os::ConnectionWriter& connection) const +{ + return cmd.write(connection); +} + +bool ISpeechTranscriptionMsgs_get_language_helper::read(yarp::os::ConnectionReader& connection) +{ + return reply.read(connection); +} + +bool ISpeechTranscriptionMsgs_get_language_helper::Command::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(s_cmd_len)) { + return false; + } + return write(writer); +} + +bool ISpeechTranscriptionMsgs_get_language_helper::Command::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListHeader()) { + reader.fail(); + return false; + } + return read(reader); +} + +bool ISpeechTranscriptionMsgs_get_language_helper::Command::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writeTag(writer)) { + return false; + } + if (!writeArgs(writer)) { + return false; + } + return true; +} + +bool ISpeechTranscriptionMsgs_get_language_helper::Command::writeTag(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeTag(s_tag, 1, s_tag_len)) { + return false; + } + return true; +} + +bool ISpeechTranscriptionMsgs_get_language_helper::Command::writeArgs(const yarp::os::idl::WireWriter& writer [[maybe_unused]]) const +{ + return true; +} + +bool ISpeechTranscriptionMsgs_get_language_helper::Command::read(yarp::os::idl::WireReader& reader) +{ + if (!readTag(reader)) { + return false; + } + if (!readArgs(reader)) { + return false; + } + return true; +} + +bool ISpeechTranscriptionMsgs_get_language_helper::Command::readTag(yarp::os::idl::WireReader& reader) +{ + std::string tag = reader.readTag(s_tag_len); + if (reader.isError()) { + return false; + } + if (tag != s_tag) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechTranscriptionMsgs_get_language_helper::Command::readArgs(yarp::os::idl::WireReader& reader) +{ + if (!reader.noMore()) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechTranscriptionMsgs_get_language_helper::Reply::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + return write(writer); +} + +bool ISpeechTranscriptionMsgs_get_language_helper::Reply::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + return read(reader); +} + +bool ISpeechTranscriptionMsgs_get_language_helper::Reply::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.isNull()) { + if (!writer.writeListHeader(s_reply_len)) { + return false; + } + if (!writer.write(return_helper)) { + return false; + } + } + return true; +} + +bool ISpeechTranscriptionMsgs_get_language_helper::Reply::read(yarp::os::idl::WireReader& reader) +{ + if (!reader.readListReturn()) { + return false; + } + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.read(return_helper)) { + reader.fail(); + return false; + } + return true; +} + +void ISpeechTranscriptionMsgs_get_language_helper::call(ISpeechTranscriptionMsgs* ptr) +{ + reply.return_helper = ptr->get_language(); +} + +// transcribe helper class implementation +ISpeechTranscriptionMsgs_transcribe_helper::ISpeechTranscriptionMsgs_transcribe_helper(const yarp::sig::Sound& sound) : + cmd{sound} +{ +} + +bool ISpeechTranscriptionMsgs_transcribe_helper::write(yarp::os::ConnectionWriter& connection) const +{ + return cmd.write(connection); +} + +bool ISpeechTranscriptionMsgs_transcribe_helper::read(yarp::os::ConnectionReader& connection) +{ + return reply.read(connection); +} + +ISpeechTranscriptionMsgs_transcribe_helper::Command::Command(const yarp::sig::Sound& sound) : + sound{sound} +{ +} + +bool ISpeechTranscriptionMsgs_transcribe_helper::Command::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(s_cmd_len)) { + return false; + } + return write(writer); +} + +bool ISpeechTranscriptionMsgs_transcribe_helper::Command::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListHeader()) { + reader.fail(); + return false; + } + return read(reader); +} + +bool ISpeechTranscriptionMsgs_transcribe_helper::Command::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writeTag(writer)) { + return false; + } + if (!writeArgs(writer)) { + return false; + } + return true; +} + +bool ISpeechTranscriptionMsgs_transcribe_helper::Command::writeTag(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeTag(s_tag, 1, s_tag_len)) { + return false; + } + return true; +} + +bool ISpeechTranscriptionMsgs_transcribe_helper::Command::writeArgs(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeNested(sound)) { + return false; + } + return true; +} + +bool ISpeechTranscriptionMsgs_transcribe_helper::Command::read(yarp::os::idl::WireReader& reader) +{ + if (!readTag(reader)) { + return false; + } + if (!readArgs(reader)) { + return false; + } + return true; +} + +bool ISpeechTranscriptionMsgs_transcribe_helper::Command::readTag(yarp::os::idl::WireReader& reader) +{ + std::string tag = reader.readTag(s_tag_len); + if (reader.isError()) { + return false; + } + if (tag != s_tag) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechTranscriptionMsgs_transcribe_helper::Command::readArgs(yarp::os::idl::WireReader& reader) +{ + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readNested(sound)) { + reader.fail(); + return false; + } + if (!reader.noMore()) { + reader.fail(); + return false; + } + return true; +} + +bool ISpeechTranscriptionMsgs_transcribe_helper::Reply::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + return write(writer); +} + +bool ISpeechTranscriptionMsgs_transcribe_helper::Reply::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + return read(reader); +} + +bool ISpeechTranscriptionMsgs_transcribe_helper::Reply::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.isNull()) { + if (!writer.writeListHeader(s_reply_len)) { + return false; + } + if (!writer.write(return_helper)) { + return false; + } + } + return true; +} + +bool ISpeechTranscriptionMsgs_transcribe_helper::Reply::read(yarp::os::idl::WireReader& reader) +{ + if (!reader.readListReturn()) { + return false; + } + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.read(return_helper)) { + reader.fail(); + return false; + } + return true; +} + +void ISpeechTranscriptionMsgs_transcribe_helper::call(ISpeechTranscriptionMsgs* ptr) +{ + reply.return_helper = ptr->transcribe(cmd.sound); +} + +// Constructor +ISpeechTranscriptionMsgs::ISpeechTranscriptionMsgs() +{ + yarp().setOwner(*this); +} + +bool ISpeechTranscriptionMsgs::set_language(const std::string& language) +{ + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", ISpeechTranscriptionMsgs_set_language_helper::s_prototype); + } + ISpeechTranscriptionMsgs_set_language_helper helper{language}; + bool ok = yarp().write(helper, helper); + return ok ? helper.reply.return_helper : bool{}; +} + +return_get_language ISpeechTranscriptionMsgs::get_language() +{ + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", ISpeechTranscriptionMsgs_get_language_helper::s_prototype); + } + ISpeechTranscriptionMsgs_get_language_helper helper{}; + bool ok = yarp().write(helper, helper); + return ok ? helper.reply.return_helper : return_get_language{}; +} + +return_transcribe ISpeechTranscriptionMsgs::transcribe(const yarp::sig::Sound& sound) +{ + if (!yarp().canWrite()) { + yError("Missing server method '%s'?", ISpeechTranscriptionMsgs_transcribe_helper::s_prototype); + } + ISpeechTranscriptionMsgs_transcribe_helper helper{sound}; + bool ok = yarp().write(helper, helper); + return ok ? helper.reply.return_helper : return_transcribe{}; +} + +// help method +std::vector ISpeechTranscriptionMsgs::help(const std::string& functionName) +{ + bool showAll = (functionName == "--all"); + std::vector helpString; + if (showAll) { + helpString.emplace_back("*** Available commands:"); + helpString.emplace_back(ISpeechTranscriptionMsgs_set_language_helper::s_tag); + helpString.emplace_back(ISpeechTranscriptionMsgs_get_language_helper::s_tag); + helpString.emplace_back(ISpeechTranscriptionMsgs_transcribe_helper::s_tag); + helpString.emplace_back("help"); + } else { + if (functionName == ISpeechTranscriptionMsgs_set_language_helper::s_tag) { + helpString.emplace_back(ISpeechTranscriptionMsgs_set_language_helper::s_prototype); + } + if (functionName == ISpeechTranscriptionMsgs_get_language_helper::s_tag) { + helpString.emplace_back(ISpeechTranscriptionMsgs_get_language_helper::s_prototype); + } + if (functionName == ISpeechTranscriptionMsgs_transcribe_helper::s_tag) { + helpString.emplace_back(ISpeechTranscriptionMsgs_transcribe_helper::s_prototype); + } + if (functionName == "help") { + helpString.emplace_back("std::vector help(const std::string& functionName = \"--all\")"); + helpString.emplace_back("Return list of available commands, or help message for a specific function"); + helpString.emplace_back("@param functionName name of command for which to get a detailed description. If none or '--all' is provided, print list of available commands"); + helpString.emplace_back("@return list of strings (one string per line)"); + } + } + if (helpString.empty()) { + helpString.emplace_back("Command not found"); + } + return helpString; +} + +// read from ConnectionReader +bool ISpeechTranscriptionMsgs::read(yarp::os::ConnectionReader& connection) +{ + constexpr size_t max_tag_len = 2; + size_t tag_len = 1; + + yarp::os::idl::WireReader reader(connection); + reader.expectAccept(); + if (!reader.readListHeader()) { + reader.fail(); + return false; + } + + std::string tag = reader.readTag(1); + bool direct = (tag == "__direct__"); + if (direct) { + tag = reader.readTag(1); + } + while (tag_len <= max_tag_len && !reader.isError()) { + if (tag == ISpeechTranscriptionMsgs_set_language_helper::s_tag) { + ISpeechTranscriptionMsgs_set_language_helper helper; + if (!helper.cmd.readArgs(reader)) { + return false; + } + + helper.call(this); + + yarp::os::idl::WireWriter writer(reader); + if (!helper.reply.write(writer)) { + return false; + } + reader.accept(); + return true; + } + if (tag == ISpeechTranscriptionMsgs_get_language_helper::s_tag) { + ISpeechTranscriptionMsgs_get_language_helper helper; + if (!helper.cmd.readArgs(reader)) { + return false; + } + + helper.call(this); + + yarp::os::idl::WireWriter writer(reader); + if (!helper.reply.write(writer)) { + return false; + } + reader.accept(); + return true; + } + if (tag == ISpeechTranscriptionMsgs_transcribe_helper::s_tag) { + ISpeechTranscriptionMsgs_transcribe_helper helper; + if (!helper.cmd.readArgs(reader)) { + return false; + } + + helper.call(this); + + yarp::os::idl::WireWriter writer(reader); + if (!helper.reply.write(writer)) { + return false; + } + reader.accept(); + return true; + } + if (tag == "help") { + std::string functionName; + if (!reader.readString(functionName)) { + functionName = "--all"; + } + auto help_strings = help(functionName); + yarp::os::idl::WireWriter writer(reader); + if (!writer.isNull()) { + if (!writer.writeListHeader(2)) { + return false; + } + if (!writer.writeTag("many", 1, 0)) { + return false; + } + if (!writer.writeListBegin(0, help_strings.size())) { + return false; + } + for (const auto& help_string : help_strings) { + if (!writer.writeString(help_string)) { + return false; + } + } + if (!writer.writeListEnd()) { + return false; + } + } + reader.accept(); + return true; + } + if (reader.noMore()) { + reader.fail(); + return false; + } + std::string next_tag = reader.readTag(1); + if (next_tag.empty()) { + break; + } + tag.append("_").append(next_tag); + tag_len = std::count(tag.begin(), tag.end(), '_') + 1; + } + return false; +} diff --git a/src/devices/ISpeechTranscriptionMsgs/idl_generated_code/ISpeechTranscriptionMsgs.h b/src/devices/ISpeechTranscriptionMsgs/idl_generated_code/ISpeechTranscriptionMsgs.h new file mode 100644 index 0000000000..354fe008a8 --- /dev/null +++ b/src/devices/ISpeechTranscriptionMsgs/idl_generated_code/ISpeechTranscriptionMsgs.h @@ -0,0 +1,40 @@ +/* + * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +// Autogenerated by Thrift Compiler (0.14.1-yarped) +// +// This is an automatically generated file. +// It could get re-generated if the ALLOW_IDL_GENERATION flag is on. + +#ifndef YARP_THRIFT_GENERATOR_SERVICE_ISPEECHTRANSCRIPTIONMSGS_H +#define YARP_THRIFT_GENERATOR_SERVICE_ISPEECHTRANSCRIPTIONMSGS_H + +#include +#include +#include +#include +#include + +class ISpeechTranscriptionMsgs : + public yarp::os::Wire +{ +public: + // Constructor + ISpeechTranscriptionMsgs(); + + virtual bool set_language(const std::string& language); + + virtual return_get_language get_language(); + + virtual return_transcribe transcribe(const yarp::sig::Sound& sound); + + // help method + virtual std::vector help(const std::string& functionName = "--all"); + + // read from ConnectionReader + bool read(yarp::os::ConnectionReader& connection) override; +}; + +#endif // YARP_THRIFT_GENERATOR_SERVICE_ISPEECHTRANSCRIPTIONMSGS_H diff --git a/src/devices/ISpeechTranscriptionMsgs/idl_generated_code/ISpeechTranscriptionMsgs_index.txt b/src/devices/ISpeechTranscriptionMsgs/idl_generated_code/ISpeechTranscriptionMsgs_index.txt new file mode 100644 index 0000000000..42752861ef --- /dev/null +++ b/src/devices/ISpeechTranscriptionMsgs/idl_generated_code/ISpeechTranscriptionMsgs_index.txt @@ -0,0 +1,6 @@ +return_get_language.h +return_get_language.cpp +return_transcribe.h +return_transcribe.cpp +ISpeechTranscriptionMsgs.h +ISpeechTranscriptionMsgs.cpp diff --git a/src/devices/ISpeechTranscriptionMsgs/idl_generated_code/return_get_language.cpp b/src/devices/ISpeechTranscriptionMsgs/idl_generated_code/return_get_language.cpp new file mode 100644 index 0000000000..bbd24b5101 --- /dev/null +++ b/src/devices/ISpeechTranscriptionMsgs/idl_generated_code/return_get_language.cpp @@ -0,0 +1,168 @@ +/* + * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +// Autogenerated by Thrift Compiler (0.14.1-yarped) +// +// This is an automatically generated file. +// It could get re-generated if the ALLOW_IDL_GENERATION flag is on. + +#include + +// Constructor with field values +return_get_language::return_get_language(const bool ret, + const std::string& language) : + WirePortable(), + ret(ret), + language(language) +{ +} + +// Read structure on a Wire +bool return_get_language::read(yarp::os::idl::WireReader& reader) +{ + if (!read_ret(reader)) { + return false; + } + if (!read_language(reader)) { + return false; + } + if (reader.isError()) { + return false; + } + return true; +} + +// Read structure on a Connection +bool return_get_language::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListHeader(2)) { + return false; + } + if (!read(reader)) { + return false; + } + return true; +} + +// Write structure on a Wire +bool return_get_language::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!write_ret(writer)) { + return false; + } + if (!write_language(writer)) { + return false; + } + if (writer.isError()) { + return false; + } + return true; +} + +// Write structure on a Connection +bool return_get_language::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(2)) { + return false; + } + if (!write(writer)) { + return false; + } + return true; +} + +// Convert to a printable string +std::string return_get_language::toString() const +{ + yarp::os::Bottle b; + if (!yarp::os::Portable::copyPortable(*this, b)) { + return {}; + } + return b.toString(); +} + +// read ret field +bool return_get_language::read_ret(yarp::os::idl::WireReader& reader) +{ + if (!reader.readBool(ret)) { + ret = false; + } + return true; +} + +// write ret field +bool return_get_language::write_ret(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeBool(ret)) { + return false; + } + return true; +} + +// read (nested) ret field +bool return_get_language::nested_read_ret(yarp::os::idl::WireReader& reader) +{ + if (!reader.readBool(ret)) { + ret = false; + } + return true; +} + +// write (nested) ret field +bool return_get_language::nested_write_ret(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeBool(ret)) { + return false; + } + return true; +} + +// read language field +bool return_get_language::read_language(yarp::os::idl::WireReader& reader) +{ + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readString(language)) { + reader.fail(); + return false; + } + return true; +} + +// write language field +bool return_get_language::write_language(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeString(language)) { + return false; + } + return true; +} + +// read (nested) language field +bool return_get_language::nested_read_language(yarp::os::idl::WireReader& reader) +{ + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readString(language)) { + reader.fail(); + return false; + } + return true; +} + +// write (nested) language field +bool return_get_language::nested_write_language(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeString(language)) { + return false; + } + return true; +} diff --git a/src/devices/ISpeechTranscriptionMsgs/idl_generated_code/return_get_language.h b/src/devices/ISpeechTranscriptionMsgs/idl_generated_code/return_get_language.h new file mode 100644 index 0000000000..a00bb6dbf6 --- /dev/null +++ b/src/devices/ISpeechTranscriptionMsgs/idl_generated_code/return_get_language.h @@ -0,0 +1,64 @@ +/* + * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +// Autogenerated by Thrift Compiler (0.14.1-yarped) +// +// This is an automatically generated file. +// It could get re-generated if the ALLOW_IDL_GENERATION flag is on. + +#ifndef YARP_THRIFT_GENERATOR_STRUCT_RETURN_GET_LANGUAGE_H +#define YARP_THRIFT_GENERATOR_STRUCT_RETURN_GET_LANGUAGE_H + +#include +#include + +class return_get_language : + public yarp::os::idl::WirePortable +{ +public: + // Fields + bool ret{false}; + std::string language{}; + + // Default constructor + return_get_language() = default; + + // Constructor with field values + return_get_language(const bool ret, + const std::string& language); + + // Read structure on a Wire + bool read(yarp::os::idl::WireReader& reader) override; + + // Read structure on a Connection + bool read(yarp::os::ConnectionReader& connection) override; + + // Write structure on a Wire + bool write(const yarp::os::idl::WireWriter& writer) const override; + + // Write structure on a Connection + bool write(yarp::os::ConnectionWriter& connection) const override; + + // Convert to a printable string + std::string toString() const; + + // If you want to serialize this class without nesting, use this helper + typedef yarp::os::idl::Unwrapped unwrapped; + +private: + // read/write ret field + bool read_ret(yarp::os::idl::WireReader& reader); + bool write_ret(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_ret(yarp::os::idl::WireReader& reader); + bool nested_write_ret(const yarp::os::idl::WireWriter& writer) const; + + // read/write language field + bool read_language(yarp::os::idl::WireReader& reader); + bool write_language(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_language(yarp::os::idl::WireReader& reader); + bool nested_write_language(const yarp::os::idl::WireWriter& writer) const; +}; + +#endif // YARP_THRIFT_GENERATOR_STRUCT_RETURN_GET_LANGUAGE_H diff --git a/src/devices/ISpeechTranscriptionMsgs/idl_generated_code/return_transcribe.cpp b/src/devices/ISpeechTranscriptionMsgs/idl_generated_code/return_transcribe.cpp new file mode 100644 index 0000000000..8191864cb3 --- /dev/null +++ b/src/devices/ISpeechTranscriptionMsgs/idl_generated_code/return_transcribe.cpp @@ -0,0 +1,222 @@ +/* + * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +// Autogenerated by Thrift Compiler (0.14.1-yarped) +// +// This is an automatically generated file. +// It could get re-generated if the ALLOW_IDL_GENERATION flag is on. + +#include + +// Constructor with field values +return_transcribe::return_transcribe(const bool ret, + const std::string& transcription, + const double score) : + WirePortable(), + ret(ret), + transcription(transcription), + score(score) +{ +} + +// Read structure on a Wire +bool return_transcribe::read(yarp::os::idl::WireReader& reader) +{ + if (!read_ret(reader)) { + return false; + } + if (!read_transcription(reader)) { + return false; + } + if (!read_score(reader)) { + return false; + } + if (reader.isError()) { + return false; + } + return true; +} + +// Read structure on a Connection +bool return_transcribe::read(yarp::os::ConnectionReader& connection) +{ + yarp::os::idl::WireReader reader(connection); + if (!reader.readListHeader(3)) { + return false; + } + if (!read(reader)) { + return false; + } + return true; +} + +// Write structure on a Wire +bool return_transcribe::write(const yarp::os::idl::WireWriter& writer) const +{ + if (!write_ret(writer)) { + return false; + } + if (!write_transcription(writer)) { + return false; + } + if (!write_score(writer)) { + return false; + } + if (writer.isError()) { + return false; + } + return true; +} + +// Write structure on a Connection +bool return_transcribe::write(yarp::os::ConnectionWriter& connection) const +{ + yarp::os::idl::WireWriter writer(connection); + if (!writer.writeListHeader(3)) { + return false; + } + if (!write(writer)) { + return false; + } + return true; +} + +// Convert to a printable string +std::string return_transcribe::toString() const +{ + yarp::os::Bottle b; + if (!yarp::os::Portable::copyPortable(*this, b)) { + return {}; + } + return b.toString(); +} + +// read ret field +bool return_transcribe::read_ret(yarp::os::idl::WireReader& reader) +{ + if (!reader.readBool(ret)) { + ret = false; + } + return true; +} + +// write ret field +bool return_transcribe::write_ret(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeBool(ret)) { + return false; + } + return true; +} + +// read (nested) ret field +bool return_transcribe::nested_read_ret(yarp::os::idl::WireReader& reader) +{ + if (!reader.readBool(ret)) { + ret = false; + } + return true; +} + +// write (nested) ret field +bool return_transcribe::nested_write_ret(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeBool(ret)) { + return false; + } + return true; +} + +// read transcription field +bool return_transcribe::read_transcription(yarp::os::idl::WireReader& reader) +{ + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readString(transcription)) { + reader.fail(); + return false; + } + return true; +} + +// write transcription field +bool return_transcribe::write_transcription(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeString(transcription)) { + return false; + } + return true; +} + +// read (nested) transcription field +bool return_transcribe::nested_read_transcription(yarp::os::idl::WireReader& reader) +{ + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readString(transcription)) { + reader.fail(); + return false; + } + return true; +} + +// write (nested) transcription field +bool return_transcribe::nested_write_transcription(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeString(transcription)) { + return false; + } + return true; +} + +// read score field +bool return_transcribe::read_score(yarp::os::idl::WireReader& reader) +{ + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readFloat64(score)) { + reader.fail(); + return false; + } + return true; +} + +// write score field +bool return_transcribe::write_score(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeFloat64(score)) { + return false; + } + return true; +} + +// read (nested) score field +bool return_transcribe::nested_read_score(yarp::os::idl::WireReader& reader) +{ + if (reader.noMore()) { + reader.fail(); + return false; + } + if (!reader.readFloat64(score)) { + reader.fail(); + return false; + } + return true; +} + +// write (nested) score field +bool return_transcribe::nested_write_score(const yarp::os::idl::WireWriter& writer) const +{ + if (!writer.writeFloat64(score)) { + return false; + } + return true; +} diff --git a/src/devices/ISpeechTranscriptionMsgs/idl_generated_code/return_transcribe.h b/src/devices/ISpeechTranscriptionMsgs/idl_generated_code/return_transcribe.h new file mode 100644 index 0000000000..21334abc0b --- /dev/null +++ b/src/devices/ISpeechTranscriptionMsgs/idl_generated_code/return_transcribe.h @@ -0,0 +1,72 @@ +/* + * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +// Autogenerated by Thrift Compiler (0.14.1-yarped) +// +// This is an automatically generated file. +// It could get re-generated if the ALLOW_IDL_GENERATION flag is on. + +#ifndef YARP_THRIFT_GENERATOR_STRUCT_RETURN_TRANSCRIBE_H +#define YARP_THRIFT_GENERATOR_STRUCT_RETURN_TRANSCRIBE_H + +#include +#include + +class return_transcribe : + public yarp::os::idl::WirePortable +{ +public: + // Fields + bool ret{false}; + std::string transcription{}; + double score{0.0}; + + // Default constructor + return_transcribe() = default; + + // Constructor with field values + return_transcribe(const bool ret, + const std::string& transcription, + const double score); + + // Read structure on a Wire + bool read(yarp::os::idl::WireReader& reader) override; + + // Read structure on a Connection + bool read(yarp::os::ConnectionReader& connection) override; + + // Write structure on a Wire + bool write(const yarp::os::idl::WireWriter& writer) const override; + + // Write structure on a Connection + bool write(yarp::os::ConnectionWriter& connection) const override; + + // Convert to a printable string + std::string toString() const; + + // If you want to serialize this class without nesting, use this helper + typedef yarp::os::idl::Unwrapped unwrapped; + +private: + // read/write ret field + bool read_ret(yarp::os::idl::WireReader& reader); + bool write_ret(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_ret(yarp::os::idl::WireReader& reader); + bool nested_write_ret(const yarp::os::idl::WireWriter& writer) const; + + // read/write transcription field + bool read_transcription(yarp::os::idl::WireReader& reader); + bool write_transcription(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_transcription(yarp::os::idl::WireReader& reader); + bool nested_write_transcription(const yarp::os::idl::WireWriter& writer) const; + + // read/write score field + bool read_score(yarp::os::idl::WireReader& reader); + bool write_score(const yarp::os::idl::WireWriter& writer) const; + bool nested_read_score(yarp::os::idl::WireReader& reader); + bool nested_write_score(const yarp::os::idl::WireWriter& writer) const; +}; + +#endif // YARP_THRIFT_GENERATOR_STRUCT_RETURN_TRANSCRIBE_H diff --git a/src/devices/fakeSpeechSynthesizer/CMakeLists.txt b/src/devices/fakeSpeechSynthesizer/CMakeLists.txt new file mode 100644 index 0000000000..19ef2e6e8d --- /dev/null +++ b/src/devices/fakeSpeechSynthesizer/CMakeLists.txt @@ -0,0 +1,50 @@ +# SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) +# SPDX-License-Identifier: BSD-3-Clause + +if (YARP_COMPILE_ALL_FAKE_DEVICES) + set(ENABLE_yarpmod_fakeSpeechSynthesizer ON CACHE BOOL "" FORCE) +endif() + +yarp_prepare_plugin(fakeSpeechSynthesizer + CATEGORY device + TYPE FakeSpeechSynthesizer + INCLUDE fakeSpeechSynthesizer.h +) + +if(ENABLE_fakeSpeechSynthesizer) + yarp_add_plugin(yarp_fakeSpeechSynthesizer) + + target_sources(yarp_fakeSpeechSynthesizer + PRIVATE + fakeSpeechSynthesizer.cpp + fakeSpeechSynthesizer.h + ) + + target_link_libraries(yarp_fakeSpeechSynthesizer + PRIVATE + YARP::YARP_os + YARP::YARP_dev + ) + list(APPEND YARP_${YARP_PLUGIN_MASTER}_PRIVATE_DEPS + YARP_os + YARP_dev + ) + + yarp_install( + TARGETS yarp_fakeSpeechSynthesizer + EXPORT YARP_${YARP_PLUGIN_MASTER} + COMPONENT ${YARP_PLUGIN_MASTER} + LIBRARY DESTINATION ${YARP_DYNAMIC_PLUGINS_INSTALL_DIR} + ARCHIVE DESTINATION ${YARP_STATIC_PLUGINS_INSTALL_DIR} + YARP_INI DESTINATION ${YARP_PLUGIN_MANIFESTS_INSTALL_DIR} + ) + + set(YARP_${YARP_PLUGIN_MASTER}_PRIVATE_DEPS ${YARP_${YARP_PLUGIN_MASTER}_PRIVATE_DEPS} PARENT_SCOPE) + + set_property(TARGET yarp_fakeSpeechSynthesizer PROPERTY FOLDER "Plugins/Device/Fake") + + if(YARP_COMPILE_TESTS) + add_subdirectory(tests) + endif() + +endif() diff --git a/src/devices/fakeSpeechSynthesizer/fakeSpeechSynthesizer.cpp b/src/devices/fakeSpeechSynthesizer/fakeSpeechSynthesizer.cpp new file mode 100644 index 0000000000..758af16332 --- /dev/null +++ b/src/devices/fakeSpeechSynthesizer/fakeSpeechSynthesizer.cpp @@ -0,0 +1,104 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "fakeSpeechSynthesizer.h" + +#include +#include +#include + +#include +#include + +using namespace yarp::os; +using namespace yarp::dev; + +namespace { +YARP_LOG_COMPONENT(FAKE_SPEECHSYN, "yarp.device.FakeSpeechSynthesizer") +} + +FakeSpeechSynthesizer::FakeSpeechSynthesizer() +{ +} + +FakeSpeechSynthesizer::~FakeSpeechSynthesizer() +{ + close(); +} + +bool FakeSpeechSynthesizer::open(yarp::os::Searchable& config) +{ + return true; +} + +bool FakeSpeechSynthesizer::close() +{ + return true; +} + +bool FakeSpeechSynthesizer::setLanguage(const std::string& language) +{ + m_language=language; + yCInfo(FAKE_SPEECHSYN) << "Language set to" << language; + return true; +} + +bool FakeSpeechSynthesizer::getLanguage(std::string& language) +{ + language = m_language; + return true; +} + +bool FakeSpeechSynthesizer::setVoice(const std::string& voice) +{ + m_voice = voice; + yCInfo(FAKE_SPEECHSYN) << "Voice set to" << voice; + return true; +} + +bool FakeSpeechSynthesizer::getVoice(std::string& voice) +{ + voice = m_voice; + return true; +} + +bool FakeSpeechSynthesizer::setSpeed(const double speed) +{ + m_speed = speed; + yCInfo(FAKE_SPEECHSYN) << "Speed set to" << speed; + return true; +} + +bool FakeSpeechSynthesizer::getSpeed(double& speed) +{ + speed = m_speed; + return true; +} + +bool FakeSpeechSynthesizer::setPitch(const double pitch) +{ + m_pitch = pitch; + yCInfo(FAKE_SPEECHSYN) << "Pitch set to" << pitch; + return true; +} + +bool FakeSpeechSynthesizer::getPitch(double& pitch) +{ + pitch = m_pitch; + return true; +} + +bool FakeSpeechSynthesizer::synthesize(const std::string& text, yarp::sig::Sound& sound) +{ + if (text == "") + { + yCError(FAKE_SPEECHSYN) << "Text is empty"; + return false; + } + + sound.resize(100,2); + + return true; +} diff --git a/src/devices/fakeSpeechSynthesizer/fakeSpeechSynthesizer.h b/src/devices/fakeSpeechSynthesizer/fakeSpeechSynthesizer.h new file mode 100644 index 0000000000..64ffe7b7ee --- /dev/null +++ b/src/devices/fakeSpeechSynthesizer/fakeSpeechSynthesizer.h @@ -0,0 +1,54 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef FAKESPEECHSYNTHESIZER_H +#define FAKESPEECHSYNTHESIZER_H + +#include +#include +#include +#include + +using namespace yarp::os; + +/** + * @ingroup dev_impl_other + * + * \brief `FakeSpeechSynthesizer`: A fake implementation of a speech synthesizer plugin. + */ +class FakeSpeechSynthesizer : + public yarp::dev::DeviceDriver, + public yarp::dev::ISpeechSynthesizer +{ +private: + bool m_verbose = true; + std::string m_language = "auto"; + std::string m_voice = "auto"; + double m_pitch = 0; + double m_speed = 0; + +public: + FakeSpeechSynthesizer(); + virtual ~FakeSpeechSynthesizer(); + FakeSpeechSynthesizer(const FakeSpeechSynthesizer&) = delete; + FakeSpeechSynthesizer(FakeSpeechSynthesizer&&) = delete; + FakeSpeechSynthesizer& operator=(const FakeSpeechSynthesizer&) = delete; + FakeSpeechSynthesizer& operator=(FakeSpeechSynthesizer&&) = delete; + + bool open(yarp::os::Searchable& config) override; + bool close() override; + + virtual bool setLanguage(const std::string& language) override; + virtual bool getLanguage(std::string& language) override; + virtual bool setVoice(const std::string& voice) override; + virtual bool getVoice(std::string& voice) override; + virtual bool setSpeed(const double speed) override; + virtual bool getSpeed(double& voice) override; + virtual bool setPitch(const double pitch) override; + virtual bool getPitch(double& voice) override; + virtual bool synthesize(const std::string& text, yarp::sig::Sound& sound) override; +}; + +#endif diff --git a/src/devices/fakeSpeechSynthesizer/tests/CMakeLists.txt b/src/devices/fakeSpeechSynthesizer/tests/CMakeLists.txt new file mode 100644 index 0000000000..4e194a2935 --- /dev/null +++ b/src/devices/fakeSpeechSynthesizer/tests/CMakeLists.txt @@ -0,0 +1,4 @@ +# SPDX-FileCopyrightText: 2023 Istituto Italiano di Tecnologia (IIT) +# SPDX-License-Identifier: BSD-3-Clause + +create_device_test(fakeSpeechSynthesizer) diff --git a/src/devices/fakeSpeechSynthesizer/tests/fakeSpeechSynthesizer_test.cpp b/src/devices/fakeSpeechSynthesizer/tests/fakeSpeechSynthesizer_test.cpp new file mode 100644 index 0000000000..76300c94e3 --- /dev/null +++ b/src/devices/fakeSpeechSynthesizer/tests/fakeSpeechSynthesizer_test.cpp @@ -0,0 +1,57 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include + +#include +#include + +using namespace yarp::dev; +using namespace yarp::os; + +TEST_CASE("dev::fakeSpeechSynthesizer", "[yarp::dev]") +{ + YARP_REQUIRE_PLUGIN("fakeSpeechSynthesizer", "device"); + + Network::setLocalMode(true); + + SECTION("Checking fakeSpeechSynthesizer device") + { + yarp::dev::ISpeechSynthesizer* istr=nullptr; + PolyDriver ddfake; + + //open the device + { + Property pdev_cfg; + pdev_cfg.put("device", "fakeSpeechSynthesizer"); + REQUIRE(ddfake.open(pdev_cfg)); + REQUIRE(ddfake.view(istr)); + } + + std::string lang = "eng"; + CHECK(istr->getLanguage(lang)); + CHECK(lang=="auto"); + + CHECK(istr->setLanguage("eng")); + CHECK(istr->getLanguage(lang)); + CHECK(lang == "eng"); + + yarp::sig::Sound snd; + CHECK(istr->synthesize("hello world",snd)); + CHECK(snd.getChannels()==2); + CHECK(snd.getSamples()==100); + + //"Close all polydrivers and check" + { + yarp::os::Time::delay(0.1); + CHECK(ddfake.close()); + } + } + + Network::setLocalMode(false); +} diff --git a/src/devices/fakeSpeechTranscription/CMakeLists.txt b/src/devices/fakeSpeechTranscription/CMakeLists.txt new file mode 100644 index 0000000000..430e65844f --- /dev/null +++ b/src/devices/fakeSpeechTranscription/CMakeLists.txt @@ -0,0 +1,50 @@ +# SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) +# SPDX-License-Identifier: BSD-3-Clause + +if (YARP_COMPILE_ALL_FAKE_DEVICES) + set(ENABLE_yarpmod_fakeSpeechTranscription ON CACHE BOOL "" FORCE) +endif() + +yarp_prepare_plugin(fakeSpeechTranscription + CATEGORY device + TYPE FakeSpeechTranscription + INCLUDE fakeSpeechTranscription.h +) + +if(ENABLE_fakeSpeechTranscription) + yarp_add_plugin(yarp_fakeSpeechTranscription) + + target_sources(yarp_fakeSpeechTranscription + PRIVATE + fakeSpeechTranscription.cpp + fakeSpeechTranscription.h + ) + + target_link_libraries(yarp_fakeSpeechTranscription + PRIVATE + YARP::YARP_os + YARP::YARP_dev + ) + list(APPEND YARP_${YARP_PLUGIN_MASTER}_PRIVATE_DEPS + YARP_os + YARP_dev + ) + + yarp_install( + TARGETS yarp_fakeSpeechTranscription + EXPORT YARP_${YARP_PLUGIN_MASTER} + COMPONENT ${YARP_PLUGIN_MASTER} + LIBRARY DESTINATION ${YARP_DYNAMIC_PLUGINS_INSTALL_DIR} + ARCHIVE DESTINATION ${YARP_STATIC_PLUGINS_INSTALL_DIR} + YARP_INI DESTINATION ${YARP_PLUGIN_MANIFESTS_INSTALL_DIR} + ) + + set(YARP_${YARP_PLUGIN_MASTER}_PRIVATE_DEPS ${YARP_${YARP_PLUGIN_MASTER}_PRIVATE_DEPS} PARENT_SCOPE) + + set_property(TARGET yarp_fakeSpeechTranscription PROPERTY FOLDER "Plugins/Device/Fake") + + if(YARP_COMPILE_TESTS) + add_subdirectory(tests) + endif() + +endif() diff --git a/src/devices/fakeSpeechTranscription/fakeSpeechTranscription.cpp b/src/devices/fakeSpeechTranscription/fakeSpeechTranscription.cpp new file mode 100644 index 0000000000..4e0e991def --- /dev/null +++ b/src/devices/fakeSpeechTranscription/fakeSpeechTranscription.cpp @@ -0,0 +1,68 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "fakeSpeechTranscription.h" + +#include +#include +#include + +#include +#include + +using namespace yarp::os; +using namespace yarp::dev; + +namespace { +YARP_LOG_COMPONENT(FAKE_SPEECHTR, "yarp.device.FakeSpeechTranscription") +} + +FakeSpeechTranscription::FakeSpeechTranscription() +{ +} + +FakeSpeechTranscription::~FakeSpeechTranscription() +{ + close(); +} + +bool FakeSpeechTranscription::open(yarp::os::Searchable& config) +{ + return true; +} + +bool FakeSpeechTranscription::close() +{ + return true; +} + +bool FakeSpeechTranscription::setLanguage(const std::string& language) +{ + m_language=language; + yCInfo(FAKE_SPEECHTR) << "Language set to" << language; + return true; +} + +bool FakeSpeechTranscription::getLanguage(std::string& language) +{ + language = m_language; + return true; +} + +bool FakeSpeechTranscription::transcribe(const yarp::sig::Sound& sound, std::string& transcription, double& score) +{ + if (sound.getSamples() == 0 || + sound.getChannels() == 0) + { + yCError(FAKE_SPEECHTR) << "Invalid Sound sample received"; + transcription = ""; + score = 0.0; + return false; + } + + transcription = "hello world"; + score = 1.0; + return true; +} diff --git a/src/devices/fakeSpeechTranscription/fakeSpeechTranscription.h b/src/devices/fakeSpeechTranscription/fakeSpeechTranscription.h new file mode 100644 index 0000000000..aa6a09706e --- /dev/null +++ b/src/devices/fakeSpeechTranscription/fakeSpeechTranscription.h @@ -0,0 +1,45 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef FAKESPEECHTRANSCRIPTION_H +#define FAKESPEECHTRANSCRIPTION_H + +#include +#include +#include +#include + +using namespace yarp::os; + +/** + * @ingroup dev_impl_other + * + * \brief `FakeSpeechTranscription`: A fake implementation of a speech transcriber plugin. + */ +class FakeSpeechTranscription : + public yarp::dev::DeviceDriver, + public yarp::dev::ISpeechTranscription +{ +private: + bool m_verbose = true; + std::string m_language="auto"; + +public: + FakeSpeechTranscription(); + virtual ~FakeSpeechTranscription(); + FakeSpeechTranscription(const FakeSpeechTranscription&) = delete; + FakeSpeechTranscription(FakeSpeechTranscription&&) = delete; + FakeSpeechTranscription& operator=(const FakeSpeechTranscription&) = delete; + FakeSpeechTranscription& operator=(FakeSpeechTranscription&&) = delete; + + bool open(yarp::os::Searchable& config) override; + bool close() override; + + virtual bool setLanguage(const std::string& language) override; + virtual bool getLanguage(std::string& language) override; + virtual bool transcribe(const yarp::sig::Sound& sound, std::string& transcription, double& score) override; +}; + +#endif diff --git a/src/devices/fakeSpeechTranscription/tests/CMakeLists.txt b/src/devices/fakeSpeechTranscription/tests/CMakeLists.txt new file mode 100644 index 0000000000..55cc32b5a6 --- /dev/null +++ b/src/devices/fakeSpeechTranscription/tests/CMakeLists.txt @@ -0,0 +1,4 @@ +# SPDX-FileCopyrightText: 2023 Istituto Italiano di Tecnologia (IIT) +# SPDX-License-Identifier: BSD-3-Clause + +create_device_test(fakeSpeechTranscription) diff --git a/src/devices/fakeSpeechTranscription/tests/fakeSpeechTranscription_test.cpp b/src/devices/fakeSpeechTranscription/tests/fakeSpeechTranscription_test.cpp new file mode 100644 index 0000000000..bff2a886dc --- /dev/null +++ b/src/devices/fakeSpeechTranscription/tests/fakeSpeechTranscription_test.cpp @@ -0,0 +1,61 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include + +#include +#include + +using namespace yarp::dev; +using namespace yarp::os; + +TEST_CASE("dev::fakeSpeechTranscription", "[yarp::dev]") +{ + YARP_REQUIRE_PLUGIN("fakeSpeechTranscription", "device"); + + Network::setLocalMode(true); + + SECTION("Checking fakeSpeechTranscription device") + { + yarp::dev::ISpeechTranscription* istr=nullptr; + PolyDriver ddfake; + + //open the device + { + + Property pdev_cfg; + pdev_cfg.put("device", "fakeSpeechTranscription"); + REQUIRE(ddfake.open(pdev_cfg)); + REQUIRE(ddfake.view(istr)); + } + + std::string lang = "eng"; + CHECK(istr->getLanguage(lang)); + CHECK(lang=="auto"); + + CHECK(istr->setLanguage("eng")); + CHECK(istr->getLanguage(lang)); + CHECK(lang == "eng"); + + std::string transcript; + double score; + yarp::sig::Sound snd; + snd.resize(100, 2); + CHECK(istr->transcribe(snd,transcript, score)); + CHECK(transcript=="hello world"); + CHECK(score > 0.99); + + //"Close all polydrivers and check" + { + yarp::os::Time::delay(0.1); + CHECK(ddfake.close()); + } + } + + Network::setLocalMode(false); +} diff --git a/src/devices/speechSynthesizer_nws_yarp/CMakeLists.txt b/src/devices/speechSynthesizer_nws_yarp/CMakeLists.txt new file mode 100644 index 0000000000..50415aa78e --- /dev/null +++ b/src/devices/speechSynthesizer_nws_yarp/CMakeLists.txt @@ -0,0 +1,52 @@ +# SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) +# SPDX-License-Identifier: BSD-3-Clause + +yarp_prepare_plugin(speechSynthesizer_nws_yarp + CATEGORY device + TYPE SpeechSynthesizer_nws_yarp + INCLUDE speechSynthesizer_nws_yarp.h + DEFAULT ON +) + +if(NOT SKIP_speechSynthesizer_nws_yarp) + yarp_add_plugin(yarp_speechSynthesizer_nws_yarp) + + target_sources(yarp_speechSynthesizer_nws_yarp + PRIVATE + speechSynthesizer_nws_yarp.cpp + speechSynthesizer_nws_yarp.h + ) + + target_link_libraries(yarp_speechSynthesizer_nws_yarp + PRIVATE + YARP::YARP_os + YARP::YARP_sig + YARP::YARP_dev + ) + list(APPEND YARP_${YARP_PLUGIN_MASTER}_PRIVATE_DEPS + YARP_os + YARP_sig + YARP_dev + ) + + target_sources(yarp_speechSynthesizer_nws_yarp PRIVATE $) + target_include_directories(yarp_speechSynthesizer_nws_yarp PRIVATE $) + + yarp_install( + TARGETS yarp_speechSynthesizer_nws_yarp + EXPORT YARP_${YARP_PLUGIN_MASTER} + COMPONENT ${YARP_PLUGIN_MASTER} + LIBRARY DESTINATION ${YARP_DYNAMIC_PLUGINS_INSTALL_DIR} + ARCHIVE DESTINATION ${YARP_STATIC_PLUGINS_INSTALL_DIR} + YARP_INI DESTINATION ${YARP_PLUGIN_MANIFESTS_INSTALL_DIR} + ) + + set(YARP_${YARP_PLUGIN_MASTER}_PRIVATE_DEPS ${YARP_${YARP_PLUGIN_MASTER}_PRIVATE_DEPS} PARENT_SCOPE) + + set_property(TARGET yarp_speechSynthesizer_nws_yarp PROPERTY FOLDER "Plugins/Device/NWS") + + if(YARP_COMPILE_TESTS) + add_subdirectory(tests) + endif() + +endif() diff --git a/src/devices/speechSynthesizer_nws_yarp/speechSynthesizer_nws_yarp.cpp b/src/devices/speechSynthesizer_nws_yarp/speechSynthesizer_nws_yarp.cpp new file mode 100644 index 0000000000..f631f43bde --- /dev/null +++ b/src/devices/speechSynthesizer_nws_yarp/speechSynthesizer_nws_yarp.cpp @@ -0,0 +1,284 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "speechSynthesizer_nws_yarp.h" + +#include +#include + +namespace { +YARP_LOG_COMPONENT(SPEECHSYNTH_NWS, "yarp.devices.speechSynthesizer_nws_yarp") +} + +SpeechSynthesizer_nws_yarp::~SpeechSynthesizer_nws_yarp() +{ + closeMain(); +} + +bool SpeechSynthesizer_nws_yarp::close() +{ + return closeMain(); +} + +bool SpeechSynthesizer_nws_yarp::open(Searchable& prop) +{ + std::string rootName = + prop.check("name",Value("/speechSynthesizer_nws"), + "prefix for port names").asString(); + + input_buffer.attach(m_inputPort); + m_inputPort.open(rootName+"/text:i"); + m_outputPort.open(rootName + "/sound:o"); + if (!m_rpcPort.open(rootName+"/rpc")) + { + yCError(SPEECHSYNTH_NWS, "Failed to open rpc port"); + return false; + } + m_rpcPort.setReader(*this); + + yCInfo(SPEECHSYNTH_NWS, "Device waiting for attach..."); + return true; +} + +void SpeechSynthesizer_nws_yarp::run() +{ + yCInfo(SPEECHSYNTH_NWS, "Starting"); + + //double before, now; + while (!isStopping()) + { + yarp::os::SystemClock::delaySystem(0.100); + //do nothing (for now..) + } + yCInfo(SPEECHSYNTH_NWS, "Stopping"); +} + +bool SpeechSynthesizer_nws_yarp::attach(yarp::dev::PolyDriver* deviceToAttach) +{ + if (deviceToAttach->isValid()) + { + deviceToAttach->view(m_isptr); + } + + if (nullptr == m_isptr) + { + yCError(SPEECHSYNTH_NWS, "Subdevice passed to attach method is invalid"); + return false; + } + + yCInfo(SPEECHSYNTH_NWS, "Attach done"); + + callback_impl = new ImplementCallbackHelper2(m_isptr,&m_outputPort); + input_buffer.useCallback(*callback_impl); + m_rpc.setInterfaces(m_isptr); + m_rpc.setOutputPort(&m_outputPort); + + start(); + return true; +} + +bool SpeechSynthesizer_nws_yarp::detach() +{ + m_isptr = nullptr; + return true; +} + +bool SpeechSynthesizer_nws_yarp::closeMain() +{ + if (Thread::isRunning()) { + Thread::stop(); + } + //close the port connection here + input_buffer.disableCallback(); + m_inputPort.close(); + m_outputPort.close(); + m_rpcPort.close(); + if (callback_impl) {delete callback_impl; callback_impl=nullptr;} + return true; +} + +bool SpeechSynthesizer_nws_yarp::read(yarp::os::ConnectionReader& connection) +{ + bool b = m_rpc.read(connection); + if (b) + { + return true; + } + else + { + yCError(SPEECHSYNTH_NWS, "read() Command failed"); + return false; + } +} + +//-------------------------------------------------- +// RPC methods +bool ISpeechSynthesizerMsgsd::set_language(const std::string& language) +{ + std::lock_guard lg(m_mutex); + if (m_isptr) + { + return m_isptr->setLanguage(language); + } + yCError(SPEECHSYNTH_NWS, "ISpeechSynthesizer interface was not set"); + return false; +} + +return_get_language ISpeechSynthesizerMsgsd::get_language() +{ + std::lock_guard lg(m_mutex); + return_get_language ret; + if (m_isptr) + { + std::string language; + bool b = m_isptr->getLanguage(language); + ret.ret = b; + ret.language = language; + return ret; + } + yCError(SPEECHSYNTH_NWS, "ISpeechSynthesizer interface was not set"); + return ret; +} + +bool ISpeechSynthesizerMsgsd::set_voice(const std::string& voice) +{ + std::lock_guard lg(m_mutex); + if (m_isptr) + { + return m_isptr->setVoice(voice); + } + yCError(SPEECHSYNTH_NWS, "ISpeechSynthesizer interface was not set"); + return false; +} + +return_get_voice ISpeechSynthesizerMsgsd::get_voice() +{ + std::lock_guard lg(m_mutex); + return_get_voice ret; + if (m_isptr) + { + std::string voice; + bool b = m_isptr->getVoice(voice); + ret.ret = b; + ret.voice = voice; + return ret; + } + yCError(SPEECHSYNTH_NWS, "ISpeechSynthesizer interface was not set"); + return ret; +} + +bool ISpeechSynthesizerMsgsd::set_pitch(double pitch) +{ + std::lock_guard lg(m_mutex); + if (m_isptr) + { + return m_isptr->setPitch(pitch); + } + yCError(SPEECHSYNTH_NWS, "ISpeechSynthesizer interface was not set"); + return false; +} + +return_get_pitch ISpeechSynthesizerMsgsd::get_pitch() +{ + std::lock_guard lg(m_mutex); + return_get_pitch ret; + if (m_isptr) + { + double pitch; + bool b = m_isptr->getPitch(pitch); + ret.ret = b; + ret.pitch = pitch; + return ret; + } + yCError(SPEECHSYNTH_NWS, "ISpeechSynthesizer interface was not set"); + return ret; +} + +bool ISpeechSynthesizerMsgsd::set_speed(double speed) +{ + std::lock_guard lg(m_mutex); + if (m_isptr) + { + return m_isptr->setSpeed(speed); + } + yCError(SPEECHSYNTH_NWS, "ISpeechSynthesizer interface was not set"); + return false; +} + +return_get_speed ISpeechSynthesizerMsgsd::get_speed() +{ + std::lock_guard lg(m_mutex); + return_get_speed ret; + if (m_isptr) + { + double speed; + bool b = m_isptr->getSpeed(speed); + ret.ret = b; + ret.speed = speed; + return ret; + } + yCError(SPEECHSYNTH_NWS, "ISpeechSynthesizer interface was not set"); + return ret; +} + +return_synthesize ISpeechSynthesizerMsgsd::synthesize(const std::string& text) +{ + std::lock_guard lg(m_mutex); + return_synthesize ret; + if (m_isptr) + { + yarp::sig::Sound snd; + double score; + bool b = m_isptr->synthesize(text, snd); + ret.ret = b; + ret.sound = snd; + + if (m_output_port && m_output_port->getOutputCount()>0) + { + m_output_port->write(snd); + } + + return ret; + } + yCError(SPEECHSYNTH_NWS, "ISpeechSynthesizer interface was not set"); + return ret; +} + +//-------------------------------------------------- +// ImplementCallbackHelper class. +ImplementCallbackHelper2::ImplementCallbackHelper2(yarp::dev::ISpeechSynthesizer*x, yarp::os::Port* p) +{ + if (x ==nullptr || p==nullptr) + { + yCError(SPEECHSYNTH_NWS, "Could not get ISpeechSynthesizer interface/output port"); + std::exit(1); + } + m_isptr = x; + m_output_port = p; +} + +void ImplementCallbackHelper2::onRead(yarp::os::Bottle &b) +{ + if (m_isptr) + { + yarp::sig::Sound snd; + bool ok = m_isptr->synthesize(b.get(0).asString(), snd); + if (!ok) + { + yCError(SPEECHSYNTH_NWS, "Problems during speech synthesis"); + } + else + { + if (m_output_port && m_output_port->getOutputCount() > 0) + { + m_output_port->write(snd); + } + } + } + else + { + yCError(SPEECHSYNTH_NWS, "ISpeechSynthesizer interface was not set"); + } +} diff --git a/src/devices/speechSynthesizer_nws_yarp/speechSynthesizer_nws_yarp.h b/src/devices/speechSynthesizer_nws_yarp/speechSynthesizer_nws_yarp.h new file mode 100644 index 0000000000..3bf4edf0a7 --- /dev/null +++ b/src/devices/speechSynthesizer_nws_yarp/speechSynthesizer_nws_yarp.h @@ -0,0 +1,127 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef YARP_DEV_SPEECHSYNTH_NWS_YARP_H +#define YARP_DEV_SPEECHSYNTH_NWS_YARP_H + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ISpeechSynthesizerMsgs.h" + +using namespace yarp::os; +using namespace yarp::sig; +using namespace yarp::dev; + +class SerialPort_nws_yarp; + +// Callback implementation after buffered input. +class ImplementCallbackHelper2 : + public yarp::os::TypedReaderCallback +{ +protected: + yarp::dev::ISpeechSynthesizer* m_isptr{nullptr}; + yarp::os::Port* m_output_port{ nullptr }; + +public: + ImplementCallbackHelper2() = delete; + ImplementCallbackHelper2(yarp::dev::ISpeechSynthesizer* x, yarp::os::Port* output_port); + virtual ~ImplementCallbackHelper2() override {}; + + using yarp::os::TypedReaderCallback::onRead; + void onRead(yarp::os::Bottle& b) override; +}; + +// rpc commands +class ISpeechSynthesizerMsgsd : public ISpeechSynthesizerMsgs +{ +private: + std::mutex m_mutex; + yarp::dev::ISpeechSynthesizer* m_isptr{ nullptr }; + yarp::os::Port* m_output_port{ nullptr }; + +public: + virtual bool set_language(const std::string& language) override; + virtual return_get_language get_language() override; + virtual bool set_voice(const std::string& language) override; + virtual return_get_voice get_voice() override; + virtual bool set_speed(double speed) override; + virtual return_get_speed get_speed() override; + virtual bool set_pitch(double pitch) override; + virtual return_get_pitch get_pitch() override; + virtual return_synthesize synthesize(const std::string& text) override; + +public: + void setInterfaces(yarp::dev::ISpeechSynthesizer* iser) { m_isptr = iser;} + void setOutputPort(yarp::os::Port* port) { m_output_port = port; } + std::mutex* getMutex() { return &m_mutex; } +}; + + +/** + * @ingroup dev_impl_nws_yarp + * + * \brief `SpeechSynthesizer_nws_yarp`: A wrapper for a plugin able to perform speech synthesis. + * + * The network interface is composed by two ports. + * When a text bottle is received on the input port, the attached subdevice processes it and generates + * a yarp::sig::Sound on the output port. + * The same functionality is available also via rpc port, which also provides additional functionalities, + * such as setting of the voice or the language. + * + * Parameters required by this device are: + * | Parameter name | SubParameter | Type | Units | Default Value | Required | Description | Notes | + * |:--------------:|:--------------:|:-------:|:--------------:|:----------------------------:|:----------: |:---------------------------------------------------------------------:|:-----:| + * | name | - | string | - | /speechSynthesizer_nws | No | full name of the port opened by the device | MUST start with a '/' character, xxx/text:i, xxx/rpc, xxx/audio:o ports are opened | + */ +class SpeechSynthesizer_nws_yarp : + public yarp::dev::DeviceDriver, + public yarp::os::Thread, + public yarp::dev::WrapperSingle, + public yarp::os::PortReader +{ +private: + yarp::dev::ISpeechSynthesizer* m_isptr{ nullptr }; + yarp::os::Port m_inputPort; + yarp::os::Port m_outputPort; + yarp::os::Port m_rpcPort; + ISpeechSynthesizerMsgsd m_rpc; + + yarp::os::PortReaderBuffer input_buffer; + ImplementCallbackHelper2* callback_impl{ nullptr }; + + // yarp::dev::IWrapper + bool attach(yarp::dev::PolyDriver* deviceToAttach) override; + bool detach() override; + +private: + bool closeMain(); + +public: + SpeechSynthesizer_nws_yarp() = default; + SpeechSynthesizer_nws_yarp(const SpeechSynthesizer_nws_yarp&) = delete; + SpeechSynthesizer_nws_yarp(SpeechSynthesizer_nws_yarp&&) = delete; + SpeechSynthesizer_nws_yarp& operator=(const SpeechSynthesizer_nws_yarp&) = delete; + SpeechSynthesizer_nws_yarp& operator=(SpeechSynthesizer_nws_yarp&&) = delete; + virtual ~SpeechSynthesizer_nws_yarp() override; + + bool open(yarp::os::Searchable& config) override; + bool close() override; + bool read(yarp::os::ConnectionReader& connection) override; + void run() override; +}; + +#endif // YARP_DEV_SPEECHSYNTH_NWS_YARP_H diff --git a/src/devices/speechSynthesizer_nws_yarp/tests/CMakeLists.txt b/src/devices/speechSynthesizer_nws_yarp/tests/CMakeLists.txt new file mode 100644 index 0000000000..79e5a5da77 --- /dev/null +++ b/src/devices/speechSynthesizer_nws_yarp/tests/CMakeLists.txt @@ -0,0 +1,4 @@ +# SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) +# SPDX-License-Identifier: BSD-3-Clause + +create_device_test(speechSynthesizer_nws_yarp) diff --git a/src/devices/speechSynthesizer_nws_yarp/tests/speechSynthesizer_nws_yarp_test.cpp b/src/devices/speechSynthesizer_nws_yarp/tests/speechSynthesizer_nws_yarp_test.cpp new file mode 100644 index 0000000000..f8fb3cd168 --- /dev/null +++ b/src/devices/speechSynthesizer_nws_yarp/tests/speechSynthesizer_nws_yarp_test.cpp @@ -0,0 +1,98 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include + +#include +#include + +#include + +using namespace yarp::dev; +using namespace yarp::os; + +TEST_CASE("dev::speechSynthesizer_nws_yarp", "[yarp::dev]") +{ + YARP_REQUIRE_PLUGIN("fakeSpeechSynthesizer", "device"); + YARP_REQUIRE_PLUGIN("speechSynthesizer_nws_yarp", "device"); + + Network::setLocalMode(true); + + SECTION("Checking speechSynthesizer_nws_yarp device alone") + { + PolyDriver dd; + + ////////"Checking opening polydriver with no attached device" + { + Property pnws_cfg; + pnws_cfg.put("device", "speechSynthesizer_nws_yarp"); + pnws_cfg.put("name", "/speechSynthesizer_nws"); + REQUIRE(dd.open(pnws_cfg)); + } + + yarp::os::Time::delay(1.0); + + //"Close all polydrivers and check" + { + CHECK(dd.close()); + } + } + + SECTION("Checking speechSynthesizer_nws_yarp device attached to fake device") + { + PolyDriver ddnws; + PolyDriver ddfake; + + ////////"Checking opening polydriver and attach device" + { + Property pnws_cfg; + pnws_cfg.put("device", "speechSynthesizer_nws_yarp"); + pnws_cfg.put("name", "/speechSynthesizer_nws"); + REQUIRE(ddnws.open(pnws_cfg)); + + Property pdev_cfg; + pdev_cfg.put("device", "fakeSpeechSynthesizer"); + REQUIRE(ddfake.open(pdev_cfg)); + + {yarp::dev::WrapperSingle* ww_nws; ddnws.view(ww_nws); + bool result_att = ww_nws->attach(&ddfake); + REQUIRE(result_att); } + } + + //tests + { + Port po; + Port pi; + CHECK(po.open("/test:o")); + CHECK(Network::connect("/test:o","/speechSynthesizer_nws/text:i")); + CHECK(pi.open("/test:i")); + CHECK(Network::connect("/speechSynthesizer_nws/sound:o", "/test:i")); + yarp::os::Time::delay(0.5); + + yarp::os::Bottle b; + b.addString("hello world"); + CHECK(po.write(b)); + yarp::os::Time::delay(0.5); + yarp::sig::Sound ss; + CHECK(pi.read(ss)); + CHECK(ss.getChannels() == 2); + CHECK(ss.getSamples() == 100); + + po.close(); + pi.close(); + } + yarp::os::Time::delay(0.5); + + //"Close all polydrivers and check" + { + CHECK(ddnws.close()); + CHECK(ddfake.close()); + } + } + + Network::setLocalMode(false); +} diff --git a/src/devices/speechTranscription_nws_yarp/CMakeLists.txt b/src/devices/speechTranscription_nws_yarp/CMakeLists.txt new file mode 100644 index 0000000000..a2a218fa54 --- /dev/null +++ b/src/devices/speechTranscription_nws_yarp/CMakeLists.txt @@ -0,0 +1,52 @@ +# SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) +# SPDX-License-Identifier: BSD-3-Clause + +yarp_prepare_plugin(speechTranscription_nws_yarp + CATEGORY device + TYPE SpeechTranscription_nws_yarp + INCLUDE speechTranscription_nws_yarp.h + DEFAULT ON +) + +if(NOT SKIP_speechTranscription_nws_yarp) + yarp_add_plugin(yarp_speechTranscription_nws_yarp) + + target_sources(yarp_speechTranscription_nws_yarp + PRIVATE + speechTranscription_nws_yarp.cpp + speechTranscription_nws_yarp.h + ) + + target_link_libraries(yarp_speechTranscription_nws_yarp + PRIVATE + YARP::YARP_os + YARP::YARP_sig + YARP::YARP_dev + ) + list(APPEND YARP_${YARP_PLUGIN_MASTER}_PRIVATE_DEPS + YARP_os + YARP_sig + YARP_dev + ) + + target_sources(yarp_speechTranscription_nws_yarp PRIVATE $) + target_include_directories(yarp_speechTranscription_nws_yarp PRIVATE $) + + yarp_install( + TARGETS yarp_speechTranscription_nws_yarp + EXPORT YARP_${YARP_PLUGIN_MASTER} + COMPONENT ${YARP_PLUGIN_MASTER} + LIBRARY DESTINATION ${YARP_DYNAMIC_PLUGINS_INSTALL_DIR} + ARCHIVE DESTINATION ${YARP_STATIC_PLUGINS_INSTALL_DIR} + YARP_INI DESTINATION ${YARP_PLUGIN_MANIFESTS_INSTALL_DIR} + ) + + set(YARP_${YARP_PLUGIN_MASTER}_PRIVATE_DEPS ${YARP_${YARP_PLUGIN_MASTER}_PRIVATE_DEPS} PARENT_SCOPE) + + set_property(TARGET yarp_speechTranscription_nws_yarp PROPERTY FOLDER "Plugins/Device/NWS") + + if(YARP_COMPILE_TESTS) + add_subdirectory(tests) + endif() + +endif() diff --git a/src/devices/speechTranscription_nws_yarp/speechTranscription_nws_yarp.cpp b/src/devices/speechTranscription_nws_yarp/speechTranscription_nws_yarp.cpp new file mode 100644 index 0000000000..344fb7583c --- /dev/null +++ b/src/devices/speechTranscription_nws_yarp/speechTranscription_nws_yarp.cpp @@ -0,0 +1,211 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "speechTranscription_nws_yarp.h" + +#include +#include + +namespace { +YARP_LOG_COMPONENT(SPEECHTR_NWS, "yarp.devices.speechTranscription_nws_yarp") +} + +SpeechTranscription_nws_yarp::~SpeechTranscription_nws_yarp() +{ + closeMain(); +} + +bool SpeechTranscription_nws_yarp::close() +{ + return closeMain(); +} + +bool SpeechTranscription_nws_yarp::open(Searchable& prop) +{ + std::string rootName = + prop.check("name",Value("/speechTranscription_nws"), + "prefix for port names").asString(); + + input_buffer.attach(m_inputPort); + m_inputPort.open(rootName+"/sound:i"); + m_outputPort.open(rootName + "/text:o"); + if (!m_rpcPort.open(rootName+"/rpc")) + { + yCError(SPEECHTR_NWS, "Failed to open rpc port"); + return false; + } + m_rpcPort.setReader(*this); + + yCInfo(SPEECHTR_NWS, "Device waiting for attach..."); + return true; +} + +void SpeechTranscription_nws_yarp::run() +{ + yCInfo(SPEECHTR_NWS, "Starting"); + + //double before, now; + while (!isStopping()) + { + yarp::os::SystemClock::delaySystem(0.100); + //do nothing (for now..) + } + yCInfo(SPEECHTR_NWS, "Stopping"); +} + +bool SpeechTranscription_nws_yarp::attach(yarp::dev::PolyDriver* deviceToAttach) +{ + if (deviceToAttach->isValid()) + { + deviceToAttach->view(m_isptr); + } + + if (nullptr == m_isptr) + { + yCError(SPEECHTR_NWS, "Subdevice passed to attach method is invalid"); + return false; + } + + yCInfo(SPEECHTR_NWS, "Attach done"); + + callback_impl = new ImplementCallbackHelper2(m_isptr,&m_outputPort); + input_buffer.useCallback(*callback_impl); + m_rpc.setInterfaces(m_isptr); + m_rpc.setOutputPort(&m_outputPort); + + start(); + return true; +} + +bool SpeechTranscription_nws_yarp::detach() +{ + m_isptr = nullptr; + return true; +} + +bool SpeechTranscription_nws_yarp::closeMain() +{ + if (Thread::isRunning()) { + Thread::stop(); + } + //close the port connection here + input_buffer.disableCallback(); + m_inputPort.close(); + m_outputPort.close(); + m_rpcPort.close(); + if (callback_impl) {delete callback_impl; callback_impl=nullptr;} + return true; +} + +bool SpeechTranscription_nws_yarp::read(yarp::os::ConnectionReader& connection) +{ + bool b = m_rpc.read(connection); + if (b) + { + return true; + } + else + { + yCError(SPEECHTR_NWS, "read() Command failed"); + return false; + } +} + +//-------------------------------------------------- +// RPC methods +bool ISpeechTranscriptionMsgsd::set_language(const std::string& language) +{ + std::lock_guard lg(m_mutex); + if (m_isptr) + { + return m_isptr->setLanguage(language); + } + yCError(SPEECHTR_NWS, "ISpeechTranscription interface was not set"); + return false; +} + +return_get_language ISpeechTranscriptionMsgsd::get_language() +{ + std::lock_guard lg(m_mutex); + return_get_language ret; + if (m_isptr) + { + std::string language; + bool b = m_isptr->getLanguage(language); + ret.ret = b; + ret.language = language; + return ret; + } + yCError(SPEECHTR_NWS, "ISpeechTranscription interface was not set"); + return ret; +} + +return_transcribe ISpeechTranscriptionMsgsd::transcribe(const yarp::sig::Sound& sound) +{ + std::lock_guard lg(m_mutex); + return_transcribe ret; + if (m_isptr) + { + std::string transcription; + double score; + bool b = m_isptr->transcribe(sound, transcription, score); + ret.ret = b; + ret.transcription = transcription; + ret.score = score; + + if (m_output_port && m_output_port->getOutputCount()>0) + { + yarp::os::Bottle bot; + bot.addString(transcription); + bot.addFloat64(score); + m_output_port->write(bot); + } + + return ret; + } + yCError(SPEECHTR_NWS, "ISpeechTranscription interface was not set"); + return ret; +} + +//-------------------------------------------------- +// ImplementCallbackHelper class. +ImplementCallbackHelper2::ImplementCallbackHelper2(yarp::dev::ISpeechTranscription*x, yarp::os::Port* p) +{ + if (x ==nullptr || p==nullptr) + { + yCError(SPEECHTR_NWS, "Could not get ISpeechTranscription interface/output port"); + std::exit(1); + } + m_isptr = x; + m_output_port = p; +} + +void ImplementCallbackHelper2::onRead(yarp::sig::Sound &b) +{ + if (m_isptr) + { + std::string transcription; + double score=0; + bool ok = m_isptr->transcribe(b, transcription, score); + if (!ok) + { + yCError(SPEECHTR_NWS, "Problems during transcription"); + } + else + { + if (m_output_port && m_output_port->getOutputCount() > 0) + { + yarp::os::Bottle b; + b.addString(transcription); + b.addFloat64(score); + m_output_port->write(b); + } + } + } + else + { + yCError(SPEECHTR_NWS, "ISpeechTranscription interface was not set"); + } +} diff --git a/src/devices/speechTranscription_nws_yarp/speechTranscription_nws_yarp.h b/src/devices/speechTranscription_nws_yarp/speechTranscription_nws_yarp.h new file mode 100644 index 0000000000..8384c41510 --- /dev/null +++ b/src/devices/speechTranscription_nws_yarp/speechTranscription_nws_yarp.h @@ -0,0 +1,120 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef YARP_DEV_SPEECHTRANSCRIPTION_NWS_YARP_H +#define YARP_DEV_SPEECHTRANSCRIPTION_NWS_YARP_H + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ISpeechTranscriptionMsgs.h" + +using namespace yarp::os; +using namespace yarp::sig; +using namespace yarp::dev; + +class SerialPort_nws_yarp; + +// Callback implementation after buffered input. +class ImplementCallbackHelper2 : + public yarp::os::TypedReaderCallback +{ +protected: + yarp::dev::ISpeechTranscription* m_isptr{nullptr}; + yarp::os::Port* m_output_port{ nullptr }; + +public: + ImplementCallbackHelper2() = delete; + ImplementCallbackHelper2(yarp::dev::ISpeechTranscription* x, yarp::os::Port* output_port); + virtual ~ImplementCallbackHelper2() override {}; + + using yarp::os::TypedReaderCallback::onRead; + void onRead(yarp::sig::Sound& b) override; +}; + +// rpc commands +class ISpeechTranscriptionMsgsd : public ISpeechTranscriptionMsgs +{ +private: + std::mutex m_mutex; + yarp::dev::ISpeechTranscription* m_isptr{ nullptr }; + yarp::os::Port* m_output_port{ nullptr }; + +public: + virtual bool set_language(const std::string& language) override; + virtual return_get_language get_language() override; + virtual return_transcribe transcribe(const yarp::sig::Sound& sound) override; + +public: + void setInterfaces(yarp::dev::ISpeechTranscription* iser) { m_isptr = iser;} + void setOutputPort(yarp::os::Port* port) { m_output_port = port; } + std::mutex* getMutex() { return &m_mutex; } +}; + +/** + * @ingroup dev_impl_nws_yarp + * + * \brief `SpeechTranscription_nws_yarp`: A wrapper for a plugin able to perform speech transcription. + * + * The network interface is composed by two ports. + * When a yarp::sig::Sound is received on the input port, the attached subdevice processes it and sends + * the transcription on the output port. + * The same functionality is available also via rpc port, which also provides additional functionalities, + * such as setting of the transcription language. + * + * Parameters required by this device are: + * | Parameter name | SubParameter | Type | Units | Default Value | Required | Description | Notes | + * |:--------------:|:--------------:|:-------:|:--------------:|:----------------------------:|:----------: |:---------------------------------------------------------------------:|:-----:| + * | name | - | string | - | /speechTranscription_nws | No | full name of the port opened by the device | MUST start with a '/' character, xxx/audio:i, xxx/rpc, xxx/texts:o ports are opened | + */ +class SpeechTranscription_nws_yarp : + public yarp::dev::DeviceDriver, + public yarp::os::Thread, + public yarp::dev::WrapperSingle, + public yarp::os::PortReader +{ +private: + yarp::dev::ISpeechTranscription* m_isptr{ nullptr }; + yarp::os::Port m_inputPort; + yarp::os::Port m_outputPort; + yarp::os::Port m_rpcPort; + ISpeechTranscriptionMsgsd m_rpc; + + yarp::os::PortReaderBuffer input_buffer; + ImplementCallbackHelper2* callback_impl{ nullptr }; + + // yarp::dev::IWrapper + bool attach(yarp::dev::PolyDriver* deviceToAttach) override; + bool detach() override; + +private: + bool closeMain(); + +public: + SpeechTranscription_nws_yarp() = default; + SpeechTranscription_nws_yarp(const SpeechTranscription_nws_yarp&) = delete; + SpeechTranscription_nws_yarp(SpeechTranscription_nws_yarp&&) = delete; + SpeechTranscription_nws_yarp& operator=(const SpeechTranscription_nws_yarp&) = delete; + SpeechTranscription_nws_yarp& operator=(SpeechTranscription_nws_yarp&&) = delete; + virtual ~SpeechTranscription_nws_yarp() override; + + bool open(yarp::os::Searchable& config) override; + bool close() override; + bool read(yarp::os::ConnectionReader& connection) override; + void run() override; +}; + +#endif // YARP_DEV_SERIALPORT_NWS_YARP_H diff --git a/src/devices/speechTranscription_nws_yarp/tests/CMakeLists.txt b/src/devices/speechTranscription_nws_yarp/tests/CMakeLists.txt new file mode 100644 index 0000000000..152b9a0013 --- /dev/null +++ b/src/devices/speechTranscription_nws_yarp/tests/CMakeLists.txt @@ -0,0 +1,4 @@ +# SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) +# SPDX-License-Identifier: BSD-3-Clause + +create_device_test(speechTranscription_nws_yarp) diff --git a/src/devices/speechTranscription_nws_yarp/tests/speechTranscription_nws_yarp_test.cpp b/src/devices/speechTranscription_nws_yarp/tests/speechTranscription_nws_yarp_test.cpp new file mode 100644 index 0000000000..2dddef48ed --- /dev/null +++ b/src/devices/speechTranscription_nws_yarp/tests/speechTranscription_nws_yarp_test.cpp @@ -0,0 +1,98 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include + +#include +#include + +#include + +using namespace yarp::dev; +using namespace yarp::os; + +TEST_CASE("dev::speechTranscription_nws_yarp", "[yarp::dev]") +{ + YARP_REQUIRE_PLUGIN("fakeSpeechTranscription", "device"); + YARP_REQUIRE_PLUGIN("speechTranscription_nws_yarp", "device"); + + Network::setLocalMode(true); + + SECTION("Checking speechTranscription_nws_yarp device alone") + { + PolyDriver dd; + + ////////"Checking opening polydriver with no attached device" + { + Property pnws_cfg; + pnws_cfg.put("device", "speechTranscription_nws_yarp"); + pnws_cfg.put("name", "/speechTranscription_nws"); + REQUIRE(dd.open(pnws_cfg)); + } + + yarp::os::Time::delay(1.0); + + //"Close all polydrivers and check" + { + CHECK(dd.close()); + } + } + + SECTION("Checking speechTranscription_nws_yarp device attached to fake device") + { + PolyDriver ddnws; + PolyDriver ddfake; + + ////////"Checking opening polydriver and attach device" + { + Property pnws_cfg; + pnws_cfg.put("device", "speechTranscription_nws_yarp"); + pnws_cfg.put("name", "/speechTranscription_nws"); + REQUIRE(ddnws.open(pnws_cfg)); + + Property pdev_cfg; + pdev_cfg.put("device", "fakeSpeechTranscription"); + REQUIRE(ddfake.open(pdev_cfg)); + + {yarp::dev::WrapperSingle* ww_nws; ddnws.view(ww_nws); + bool result_att = ww_nws->attach(&ddfake); + REQUIRE(result_att); } + } + + //tests + { + Port po; + Port pi; + CHECK(po.open("/test:o")); + CHECK(Network::connect("/test:o","/speechTranscription_nws/sound:i")); + CHECK(pi.open("/test:i")); + CHECK(Network::connect("/speechTranscription_nws/text:o", "/test:i")); + yarp::os::Time::delay(0.5); + + yarp::sig::Sound s; + s.resize(100, 2); + CHECK(po.write(s)); + yarp::os::Time::delay(0.5); + yarp::os::Bottle b; + CHECK(pi.read(b)); + CHECK(b.get(0).asString() == "hello world"); + CHECK(b.get(1).asFloat64() == 1); + + po.close(); + pi.close(); + } + yarp::os::Time::delay(0.5); + + //"Close all polydrivers and check" + { + CHECK(ddnws.close()); + CHECK(ddfake.close()); + } + } + + Network::setLocalMode(false); +} diff --git a/src/libYARP_dev/src/CMakeLists.txt b/src/libYARP_dev/src/CMakeLists.txt index 3dff6ae772..97c04930d2 100644 --- a/src/libYARP_dev/src/CMakeLists.txt +++ b/src/libYARP_dev/src/CMakeLists.txt @@ -74,6 +74,8 @@ set(YARP_dev_HDRS yarp/dev/IRgbVisualParams.h yarp/dev/IRobotDescription.h yarp/dev/ISerialDevice.h + yarp/dev/ISpeechSynthesizer.h + yarp/dev/ISpeechTranscription.h yarp/dev/ITorqueControl.h yarp/dev/IVelocityControl.h yarp/dev/IVirtualAnalogSensor.h @@ -183,6 +185,8 @@ set(YARP_dev_SRCS yarp/dev/IRgbVisualParams.cpp yarp/dev/IRobotDescription.cpp yarp/dev/ISerialDevice.cpp + yarp/dev/ISpeechSynthesizer.cpp + yarp/dev/ISpeechTranscription.cpp yarp/dev/IVisualServoing.cpp yarp/dev/IWrapper.cpp yarp/dev/ImplementAmplifierControl.cpp diff --git a/src/libYARP_dev/src/yarp/dev/ISpeechSynthesizer.cpp b/src/libYARP_dev/src/yarp/dev/ISpeechSynthesizer.cpp new file mode 100644 index 0000000000..50c49523ed --- /dev/null +++ b/src/libYARP_dev/src/yarp/dev/ISpeechSynthesizer.cpp @@ -0,0 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +yarp::dev::ISpeechSynthesizer::~ISpeechSynthesizer() = default; diff --git a/src/libYARP_dev/src/yarp/dev/ISpeechSynthesizer.h b/src/libYARP_dev/src/yarp/dev/ISpeechSynthesizer.h new file mode 100644 index 0000000000..922ff66abf --- /dev/null +++ b/src/libYARP_dev/src/yarp/dev/ISpeechSynthesizer.h @@ -0,0 +1,91 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef YARP_DEV_ISPEECHSYNTHESIZER_H +#define YARP_DEV_ISPEECHSYNTHESIZER_H + +#include +#include + +namespace yarp::dev { + +/** + * \ingroup dev_iface_other + * + * \brief A generic interface for speech synthesis. + */ +class YARP_dev_API ISpeechSynthesizer +{ +public: + virtual ~ISpeechSynthesizer(); + + /** + * Sets the language for speech synthesis. + * \param language a string (code) representing the speech language (e.g. ita, eng...). Default value is "auto". + * \return true on success + */ + virtual bool setLanguage(const std::string& language="auto") = 0; + + /** + * Gets the current language set for speech synthesis. + * \param language the returned string (code) representing the speech language (e.g. ita, eng...). Default value is "auto". + * \return true on success + */ + virtual bool getLanguage(std::string& language) = 0; + + /** + * Sets the voice set for speech synthesis. + * \param voice_name the name of of the voice (device dependent). + * \return true on success + */ + virtual bool setVoice(const std::string& voice_name = "auto") = 0; + + /** + * Gets the current voice set for speech synthesis. + * \param voice_name the currently used voice (device dependent). + * \return true on success + */ + virtual bool getVoice(std::string& voice_name) = 0; + + /** + * Sets the voice speed for speech synthesis. + * \param speed the voice speed. + * \return true on success + */ + virtual bool setSpeed(const double speed=0) = 0; + + /** + * Gets the current voice speed. + * \param speed the current voice speed. + * \return true on success + */ + virtual bool getSpeed(double& speed) = 0; + + /** + * Sets the pitch for speech synthesis. + * \param pitch the voice pitch. + * \return true on success + */ + virtual bool setPitch(const double pitch) = 0; + + /** + * Gets the current pitch set for speech synthesis. + * \param pitch the current voice pitch. + * \return true on success + */ + virtual bool getPitch(double& voice) = 0; + + /** + * Performs the speech synthesis. + * \param text the text to synthesize + * \param sound the synthesized audio stream + * \return true on success + */ + virtual bool synthesize(const std::string& text, yarp::sig::Sound& sound) = 0; +}; + +} // namespace yarp::dev + +#endif // YARP_DEV_ISPEECHSYNTHESIZER_H diff --git a/src/libYARP_dev/src/yarp/dev/ISpeechTranscription.cpp b/src/libYARP_dev/src/yarp/dev/ISpeechTranscription.cpp new file mode 100644 index 0000000000..35778855de --- /dev/null +++ b/src/libYARP_dev/src/yarp/dev/ISpeechTranscription.cpp @@ -0,0 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +yarp::dev::ISpeechTranscription::~ISpeechTranscription() = default; diff --git a/src/libYARP_dev/src/yarp/dev/ISpeechTranscription.h b/src/libYARP_dev/src/yarp/dev/ISpeechTranscription.h new file mode 100644 index 0000000000..d68d0997c4 --- /dev/null +++ b/src/libYARP_dev/src/yarp/dev/ISpeechTranscription.h @@ -0,0 +1,50 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef YARP_DEV_ISPEECHTRANSCRIPTION_H +#define YARP_DEV_ISPEECHTRANSCRIPTION_H + +#include +#include + +namespace yarp::dev { + +/** + * \ingroup dev_iface_other + * + * \brief A generic interface for speech transcription. + */ +class YARP_dev_API ISpeechTranscription +{ +public: + virtual ~ISpeechTranscription(); + + /** + * Sets the language for speech transcription. + * \param language a string (code) representing the speech language (e.g. ita, eng...). Default value is "auto". + * \return true on success + */ + virtual bool setLanguage(const std::string& language="auto") = 0; + + /** + * Gets the current language set for speech transcription. + * \param language the returned string (code) representing the speech language (e.g. ita, eng...). Default value is "auto". + * \return true on success + */ + virtual bool getLanguage(std::string& language) = 0; + + /** + * Performs the speech transcription. + * \param sound the audio data to transcribe + * \param transcription the returned transcription (it may be empty) + * \param score the returned score/confidence value in the range (0-1.0). It may be not implemented. + * \return true on success + */ + virtual bool transcribe(const yarp::sig::Sound& sound, std::string& transcription, double& score) = 0; +}; + +} // namespace yarp::dev + +#endif // YARP_DEV_ISPEECHTRANSCRIPTION_H diff --git a/tests/misc/check_tests_skip.txt b/tests/misc/check_tests_skip.txt index b79ead5936..71055f581e 100644 --- a/tests/misc/check_tests_skip.txt +++ b/tests/misc/check_tests_skip.txt @@ -6,6 +6,8 @@ ./src/devices/frameTransformStorageMsgs ./src/devices/INavigation2DMsgs ./src/devices/ISerialMsgs +./src/devices/ISpeechSynthesizerMsgs +./src/devices/ISpeechTranscriptionMsgs ./src/devices/test_segfault ./src/devices/test_nop ./src/devices/DynamixelAX12Ftdi