YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
speechSynthesizer_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::speechSynthesizer_nws_yarp", "[yarp::dev]")
19{
20 YARP_REQUIRE_PLUGIN("fakeSpeechSynthesizer", "device");
21 YARP_REQUIRE_PLUGIN("speechSynthesizer_nws_yarp", "device");
22
23 Network::setLocalMode(true);
24
25 SECTION("Checking speechSynthesizer_nws_yarp device alone")
26 {
27 PolyDriver dd;
28
30 {
32 pnws_cfg.put("device", "speechSynthesizer_nws_yarp");
33 pnws_cfg.put("name", "/speechSynthesizer_nws");
35 }
36
38
39 //"Close all polydrivers and check"
40 {
41 CHECK(dd.close());
42 }
43 }
44
45 SECTION("Checking speechSynthesizer_nws_yarp device attached to fake device")
46 {
49
51 {
53 pnws_cfg.put("device", "speechSynthesizer_nws_yarp");
54 pnws_cfg.put("name", "/speechSynthesizer_nws");
56
58 pdev_cfg.put("device", "fakeSpeechSynthesizer");
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","/speechSynthesizer_nws/text:i"));
73 CHECK(pi.open("/test:i"));
74 CHECK(Network::connect("/speechSynthesizer_nws/sound:o", "/test:i"));
76
78 b.addString("hello world");
79 CHECK(po.write(b));
82 CHECK(pi.read(ss));
83 CHECK(ss.getChannels() == 2);
84 CHECK(ss.getSamples() == 100);
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
void addString(const char *str)
Places a string in the bottle, at the end of the list.
Definition Bottle.cpp:170
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
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.
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::speechSynthesizer_nws_yarp", "[yarp::dev]")