YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
speechTranscription_nws_yarp_test.cpp
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#include <yarp/os/Network.h>
9
10#include <catch2/catch_amalgamated.hpp>
11#include <harness.h>
12
13#include <yarp/sig/Sound.h>
14
15using namespace yarp::dev;
16using namespace yarp::os;
17
18TEST_CASE("dev::speechTranscription_nws_yarp", "[yarp::dev]")
19{
20 YARP_REQUIRE_PLUGIN("fakeSpeechTranscription", "device");
21 YARP_REQUIRE_PLUGIN("speechTranscription_nws_yarp", "device");
22
23 Network::setLocalMode(true);
24
25 SECTION("Checking speechTranscription_nws_yarp device alone")
26 {
27 PolyDriver dd;
28
30 {
32 pnws_cfg.put("device", "speechTranscription_nws_yarp");
33 pnws_cfg.put("name", "/speechTranscription_nws");
35 }
36
38
39 //"Close all polydrivers and check"
40 {
41 CHECK(dd.close());
42 }
43 }
44
45 SECTION("Checking speechTranscription_nws_yarp device attached to fake device")
46 {
49
51 {
53 pnws_cfg.put("device", "speechTranscription_nws_yarp");
54 pnws_cfg.put("name", "/speechTranscription_nws");
56
58 pdev_cfg.put("device", "fakeSpeechTranscription");
60
63 bool result_att = ww_nws->attach(&ddfake);
65 }
66
67 //tests
68 {
69 Port po;
70 Port pi;
71 CHECK(po.open("/test:o"));
72 CHECK(Network::connect("/test:o","/speechTranscription_nws/sound:i"));
73 CHECK(pi.open("/test:i"));
74 CHECK(Network::connect("/speechTranscription_nws/text:o", "/test:i"));
76
78 s.resize(100, 2);
79 CHECK(po.write(s));
82 CHECK(pi.read(b));
83 CHECK(b.get(0).asString() == "hello world");
84 CHECK(b.get(1).asFloat64() == 1);
85
86 po.close();
87 pi.close();
88 }
90
91 //"Close all polydrivers and check"
92 {
93 CHECK(ddnws.close());
95 }
96 }
97
98 Network::setLocalMode(false);
99}
A container for a device driver.
Definition PolyDriver.h:23
bool close() override
Close the DeviceDriver.
bool open(const std::string &txt)
Construct and configure a device by its common name.
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
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition Bottle.cpp:246
A mini-server for performing network communication in the background.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
T * read(bool shouldWait=true) override
Read an available object from the port.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
A mini-server for network communication.
Definition Port.h:46
A class for storing options and configuration information.
Definition Property.h:33
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
Definition Value.cpp:222
virtual std::string asString() const
Get string value.
Definition Value.cpp:234
Class for storing sounds See Audio in YARP for additional documentation on YARP audio.
Definition Sound.h:25
void resize(size_t samples, size_t channels=1)
Set the sound size.
Definition Sound.cpp:270
For streams capable of holding different kinds of content, check what they actually have.
void delay(double seconds)
Wait for a certain number of seconds.
Definition Time.cpp:111
An interface to the operating system, including Port based communication.
TEST_CASE("dev::speechTranscription_nws_yarp", "[yarp::dev]")