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
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::speechSynthesizer_nwc_yarp", "[yarp::dev]")
20{
21 YARP_REQUIRE_PLUGIN("fakeSpeechSynthesizer", "device");
22 YARP_REQUIRE_PLUGIN("speechSynthesizer_nws_yarp", "device");
23 YARP_REQUIRE_PLUGIN("speechSynthesizer_nwc_yarp", "device");
24
25 Network::setLocalMode(true);
26
27
28 SECTION("Checking speechSynthesizer_nwc_yarp device")
29 {
34
36 {
38 pnws_cfg.put("device", "speechSynthesizer_nws_yarp");
39 pnws_cfg.put("name", "/speechSynthesizer_nws_yarp");
41
43 pdev_cfg.put("device", "fakeSpeechSynthesizer");
45
48 bool result_att = ww_nws->attach(&ddfake);
50
52 pclient_cfg.put("device", "speechSynthesizer_nwc_yarp");
53 pclient_cfg.put("local", "/speechSynthesizer_nwc_yarp");
54 pclient_cfg.put("remote", "/speechSynthesizer_nws_yarp");
56 REQUIRE(ddnwc.view(iSpeech));
57 }
58
60
61
62 std::string text = "hello world";
64 CHECK(iSpeech->synthesize(text,ss));
65 CHECK(ss.getChannels() == 2);
66 CHECK(ss.getSamples() == 100);
67
68 std::string voice = "voice_place_holder";
69 std::string voiceReturned;
70 double pitch = 100;
71 double pitchReturned;
72 double speed = 100;
73 double speedReturned;
74
75 CHECK(iSpeech->setLanguage("ENG"));
76 std::string getLang;
77 CHECK(iSpeech->getLanguage(getLang));
78 CHECK(getLang == "ENG");
79
81 CHECK(!iSpeech->synthesize("",ss2));
82 CHECK(ss2.getSamples() == 0);
83
84 CHECK(iSpeech->setVoice(voice));
85 CHECK(iSpeech->getVoice(voiceReturned));
86 CHECK(voice == voiceReturned);
87 CHECK(iSpeech->setPitch(pitch));
88 CHECK(iSpeech->getPitch(pitchReturned));
89 CHECK(pitch == pitchReturned);
90 CHECK(iSpeech->setSpeed(speed));
91 CHECK(iSpeech->getSpeed(speedReturned));
92 CHECK(voice == voiceReturned);
93
94 //"Close all polydrivers and check"
95 {
96 CHECK(ddnwc.close());
97 CHECK(ddnws.close());
99 }
100 }
101
102 Network::setLocalMode(false);
103}
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: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_nwc_yarp", "[yarp::dev]")