YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
speechSynthesizer_nwc_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>
10
12#include <catch2/catch_amalgamated.hpp>
13#include <harness.h>
14
15#include <yarp/sig/Sound.h>
16
17using namespace yarp::dev;
18using namespace yarp::os;
19
20TEST_CASE("dev::speechSynthesizer_nwc_yarp", "[yarp::dev]")
21{
22 YARP_REQUIRE_PLUGIN("fakeSpeechSynthesizer", "device");
23 YARP_REQUIRE_PLUGIN("speechSynthesizer_nws_yarp", "device");
24 YARP_REQUIRE_PLUGIN("speechSynthesizer_nwc_yarp", "device");
25
26 Network::setLocalMode(true);
27
28
29 SECTION("Checking speechSynthesizer_nwc_yarp device")
30 {
35
37 {
39 pnws_cfg.put("device", "speechSynthesizer_nws_yarp");
40 pnws_cfg.put("name", "/speechSynthesizer_nws_yarp");
42
44 pdev_cfg.put("device", "fakeSpeechSynthesizer");
46
49 bool result_att = ww_nws->attach(&ddfake);
51
53 pclient_cfg.put("device", "speechSynthesizer_nwc_yarp");
54 pclient_cfg.put("local", "/speechSynthesizer_nwc_yarp");
55 pclient_cfg.put("remote", "/speechSynthesizer_nws_yarp");
58
59 REQUIRE(ddnwc.view(iSpeech));
60 }
61
63
64
65 std::string text = "hello world";
67 CHECK(iSpeech->synthesize(text,ss));
68 CHECK(ss.getChannels() == 2);
69 CHECK(ss.getSamples() == 100);
70
71 std::string voice = "voice_place_holder";
72 std::string voiceReturned;
73 double pitch = 100;
74 double pitchReturned;
75 double speed = 100;
76 double speedReturned;
77 yarp::sig::VectorOfString available_voices;
78
79 CHECK(iSpeech->setLanguage("ENG"));
80 std::string getLang;
81 CHECK(iSpeech->getLanguage(getLang));
82 CHECK(getLang == "ENG");
83
85 CHECK(!iSpeech->synthesize("",ss2));
86 CHECK(ss2.getSamples() == 0);
87
88 CHECK(iSpeech->setVoice(voice));
89 CHECK(iSpeech->getVoice(voiceReturned));
90 CHECK(voice == voiceReturned);
91 CHECK(iSpeech->setPitch(pitch));
92 CHECK(iSpeech->getPitch(pitchReturned));
93 CHECK(pitch == pitchReturned);
94 CHECK(iSpeech->setSpeed(speed));
95 CHECK(iSpeech->getSpeed(speedReturned));
96 CHECK(speed == speedReturned);
97 CHECK(voice == voiceReturned);
98
99 CHECK(iSpeech->getAvailableVoices(available_voices));
100 CHECK(available_voices.size() == 3);
101 CHECK(available_voices[0] == "voice1");
102 CHECK(available_voices[1] == "voice2");
103 CHECK(available_voices[2] == "voice3");
104
105 //"Close all polydrivers and check"
106 {
107 CHECK(ddnwc.close());
108 CHECK(ddnws.close());
109 CHECK(ddfake.close());
110 }
111 }
112
113 Network::setLocalMode(false);
114}
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 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.
A class for storing options and configuration information.
Definition Property.h:32
Class for storing sounds See Audio in YARP for additional documentation on YARP audio.
Definition Sound.h:39
size_t size() const
Returns the number of elements in the vector.
Definition VectorBase.h:167
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::speechSynthesizer_nwc_yarp", "[yarp::dev]")