YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
SpeechTranscription_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_SPEECHTRANSCRIPTION_NWS_YARP_H
7#define YARP_DEV_SPEECHTRANSCRIPTION_NWS_YARP_H
8
9#include <cstdio>
10#include <cstdlib>
11
13#include <yarp/dev/PolyDriver.h>
15#include <yarp/sig/Sound.h>
16#include <yarp/os/Time.h>
17#include <yarp/os/Network.h>
18#include <yarp/os/Thread.h>
19#include <yarp/os/Vocab.h>
20#include <yarp/os/Bottle.h>
21#include <yarp/os/RpcServer.h>
25
26using namespace yarp::os;
27using namespace yarp::sig;
28using namespace yarp::dev;
29
31
32// Callback implementation after buffered input.
48
49// rpc commands
51{
52private:
53 std::mutex m_mutex;
54 yarp::dev::ISpeechTranscription* m_isptr{ nullptr };
55 yarp::os::Port* m_output_port{ nullptr };
56
57public:
58 virtual return_set_language set_language(const std::string& language) override;
59 virtual return_get_language get_language() override;
60 virtual return_transcribe transcribe(const yarp::sig::Sound& sound) override;
61
62public:
64 void setOutputPort(yarp::os::Port* port) { m_output_port = port; }
65 std::mutex* getMutex() { return &m_mutex; }
66};
67
84 public yarp::os::Thread,
88{
89private:
90 yarp::dev::ISpeechTranscription* m_isptr{ nullptr };
91 yarp::os::Port m_inputPort;
92 yarp::os::Port m_outputPort;
93 yarp::os::Port m_rpcPort;
95
97 std::unique_ptr<SpeechTranscription_CallbackHelper> callback_impl;
98
99 // yarp::dev::IWrapper
100 bool attach(yarp::dev::PolyDriver* deviceToAttach) override;
101 bool detach() override;
102
103private:
104 bool closeMain();
105
106public:
112 virtual ~SpeechTranscription_nws_yarp() override;
113
114 bool open(yarp::os::Searchable& config) override;
115 bool close() override;
116 bool read(yarp::os::ConnectionReader& connection) override;
117 void run() override;
118};
119
120#endif // YARP_DEV_SERIALPORT_NWS_YARP_H
virtual return_set_language set_language(const std::string &language) override
virtual return_transcribe transcribe(const yarp::sig::Sound &sound) override
void setInterfaces(yarp::dev::ISpeechTranscription *iser)
virtual return_get_language get_language() override
void setOutputPort(yarp::os::Port *port)
serialPort_nws_yarp: Export a serial sensor.
yarp::dev::ISpeechTranscription * m_isptr
void onRead(yarp::sig::Sound &b) override
This class is the parameters parser for class SpeechTranscription_nws_yarp.
SpeechTranscription_nws_yarp: A wrapper for a plugin able to perform speech transcription.
SpeechTranscription_nws_yarp(const SpeechTranscription_nws_yarp &)=delete
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool close() override
Close the DeviceDriver.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
SpeechTranscription_nws_yarp(SpeechTranscription_nws_yarp &&)=delete
SpeechTranscription_nws_yarp & operator=(const SpeechTranscription_nws_yarp &)=delete
SpeechTranscription_nws_yarp & operator=(SpeechTranscription_nws_yarp &&)=delete
void run() override
Main body of the new thread.
Interface implemented by all device drivers.
A generic interface for speech transcription.
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 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.
Class for storing sounds See Audio in YARP for additional documentation on YARP audio.
Definition Sound.h:25
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.