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
11#include <catch2/catch_amalgamated.hpp>
12#include <harness.h>
13
14#include <yarp/sig/Sound.h>
15
16using namespace yarp::dev;
17using namespace yarp::os;
18
19TEST_CASE("dev::speechTranscription_nws_yarp", "[yarp::dev]")
20{
21 YARP_REQUIRE_PLUGIN("fakeSpeechTranscription", "device");
22 YARP_REQUIRE_PLUGIN("speechTranscription_nws_yarp", "device");
23
24 Network::setLocalMode(true);
25
26 SECTION("Checking speechTranscription_nws_yarp device alone")
27 {
28 PolyDriver dd;
29
31 {
33 pnws_cfg.put("device", "speechTranscription_nws_yarp");
34 pnws_cfg.put("name", "/speechTranscription_nws");
36 }
37
39
40 //"Close all polydrivers and check"
41 {
42 CHECK(dd.close());
43 }
44 }
45
46 SECTION("Checking speechTranscription_nws_yarp device attached to fake device")
47 {
50
52 {
54 pnws_cfg.put("device", "speechTranscription_nws_yarp");
55 pnws_cfg.put("name", "/speechTranscription_nws");
58
60 pdev_cfg.put("device", "fakeSpeechTranscription");
62
65 bool result_att = ww_nws->attach(&ddfake);
67 }
68
69 //tests
70 {
71 Port po;
72 Port pi;
73 CHECK(po.open("/test:o"));
74 CHECK(Network::connect("/test:o","/speechTranscription_nws/sound:i"));
75 CHECK(pi.open("/test:i"));
76 CHECK(Network::connect("/speechTranscription_nws/text:o", "/test:i"));
78
80 s.resize(100, 2);
81 CHECK(po.write(s));
84 CHECK(pi.read(b));
85 CHECK(b.get(0).asString() == "hello world");
86 CHECK(b.get(1).asFloat64() == 1);
87
88 po.close();
89 pi.close();
90 }
92
93 //"Close all polydrivers and check"
94 {
95 CHECK(ddnws.close());
97 }
98 }
99
100 Network::setLocalMode(false);
101}
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:247
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:32
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:240
Class for storing sounds See Audio in YARP for additional documentation on YARP audio.
Definition Sound.h:39
void resize(size_t samples, size_t channels=1)
Set the sound size.
Definition Sound.cpp:267
void exec_params_test(yarp::dev::PolyDriver *pdrv)
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]")