YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
SpeechSynthesizer_nws_yarp.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef YARP_DEV_SPEECHSYNTH_NWS_YARP_H
7#define YARP_DEV_SPEECHSYNTH_NWS_YARP_H
8
9#include <cstdio>
10#include <cstdlib>
11#include <memory>
12
14#include <yarp/dev/PolyDriver.h>
16#include <yarp/sig/Sound.h>
17#include <yarp/os/Time.h>
18#include <yarp/os/Network.h>
19#include <yarp/os/Thread.h>
20#include <yarp/os/Vocab.h>
21#include <yarp/os/Bottle.h>
22#include <yarp/os/RpcServer.h>
26
27using namespace yarp::os;
28using namespace yarp::sig;
29using namespace yarp::dev;
30
31// Callback implementation after buffered input.
47
48// rpc commands
50{
51private:
52 std::mutex m_mutex;
53 yarp::dev::ISpeechSynthesizer* m_isptr{ nullptr };
54 yarp::os::Port* m_output_port{ nullptr };
55
56public:
57 virtual return_set_language set_language(const std::string& language) override;
58 virtual return_get_language get_language() override;
59 virtual return_set_voice set_voice(const std::string& language) override;
60 virtual return_get_voice get_voice() override;
61 virtual return_set_speed set_speed(double speed) override;
62 virtual return_get_speed get_speed() override;
63 virtual return_set_pitch set_pitch(double pitch) override;
64 virtual return_get_pitch get_pitch() override;
65 virtual return_synthesize synthesize(const std::string& text) override;
66
67public:
69 void setOutputPort(yarp::os::Port* port) { m_output_port = port; }
70 std::mutex* getMutex() { return &m_mutex; }
71};
72
73
89 public yarp::os::Thread,
93{
94private:
95 yarp::dev::ISpeechSynthesizer* m_isptr{ nullptr };
96 yarp::os::Port m_inputPort;
97 yarp::os::Port m_outputPort;
98 yarp::os::Port m_rpcPort;
100
102 std::unique_ptr<SpeechSynthesizer_CallbackHelper> callback_impl;
103
104 // yarp::dev::IWrapper
105 bool attach(yarp::dev::PolyDriver* deviceToAttach) override;
106 bool detach() override;
107
108private:
109 bool closeMain();
110
111public:
117 virtual ~SpeechSynthesizer_nws_yarp() override;
118
119 bool open(yarp::os::Searchable& config) override;
120 bool close() override;
121 bool read(yarp::os::ConnectionReader& connection) override;
122 void run() override;
123};
124
125#endif // YARP_DEV_SPEECHSYNTH_NWS_YARP_H
virtual return_set_pitch set_pitch(double pitch) override
virtual return_get_pitch get_pitch() override
virtual return_set_language set_language(const std::string &language) override
virtual return_get_speed get_speed() override
virtual return_get_voice get_voice() override
virtual return_get_language get_language() override
virtual return_set_speed set_speed(double speed) override
virtual return_set_voice set_voice(const std::string &language) override
void setOutputPort(yarp::os::Port *port)
void setInterfaces(yarp::dev::ISpeechSynthesizer *iser)
virtual return_synthesize synthesize(const std::string &text) override
void onRead(yarp::os::Bottle &b) override
Callback method.
yarp::dev::ISpeechSynthesizer * m_isptr
This class is the parameters parser for class SpeechSynthesizer_nws_yarp.
SpeechSynthesizer_nws_yarp: A wrapper for a plugin able to perform speech synthesis.
SpeechSynthesizer_nws_yarp(const SpeechSynthesizer_nws_yarp &)=delete
void run() override
Main body of the new thread.
SpeechSynthesizer_nws_yarp & operator=(SpeechSynthesizer_nws_yarp &&)=delete
SpeechSynthesizer_nws_yarp()=default
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
SpeechSynthesizer_nws_yarp(SpeechSynthesizer_nws_yarp &&)=delete
SpeechSynthesizer_nws_yarp & operator=(const SpeechSynthesizer_nws_yarp &)=delete
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
bool close() override
Close the DeviceDriver.
Interface implemented by all device drivers.
A generic interface for speech synthesis.
A container for a device driver.
Definition PolyDriver.h:23
Helper interface for an object that can wrap/or "attach" to a single other device.
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:64
A mini-server for performing network communication in the background.
An interface for reading from a network connection.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition PortReader.h:24
A mini-server for network communication.
Definition Port.h:46
A base class for nested structures that can be searched.
Definition Searchable.h:31
An abstraction for a thread of execution.
Definition Thread.h:21
A callback for typed data from a port.
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.