YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
VoiceBoxSynthesizer_test.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 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
13using namespace yarp::dev;
14using namespace yarp::os;
15
16TEST_CASE("dev::voiceBoxSynthesizer_test", "[yarp::dev]")
17{
18 YARP_REQUIRE_PLUGIN("voiceBoxSynthesizer", "device");
19
20 Network::setLocalMode(true);
21
22 SECTION("Checking the device")
23 {
24 PolyDriver dd;
25
27 pcfg.put("device", "voiceBoxSynthesizer");
28 pcfg.put("base_ip", "localhost");
29 pcfg.put("base_port", "17493");
30 pcfg.put("voice", "test_API_001");
31
32 REQUIRE(dd.open(pcfg));
33
35 REQUIRE(dd.view(speech));
36 REQUIRE(speech != nullptr);
37
38 // Basic interface checks
39 CHECK(speech->setLanguage("en"));
40 std::string language;
41 CHECK(speech->getLanguage(language));
42 CHECK(language == "en");
43
44 CHECK(speech->setVoice("test_API_002"));
45 std::string voice;
46 CHECK(speech->getVoice(voice));
47 CHECK(voice == "test_API_002");
48
49 CHECK(speech->setSpeed(1.0));
50 double speed;
51 CHECK(speech->getSpeed(speed));
52 CHECK(speed == Approx(1.0));
53
54 CHECK(speech->setPitch(1.0));
55 double pitch;
56 CHECK(speech->getPitch(pitch));
57 CHECK(pitch == Approx(1.0));
58
59 yarp::sig::Sound sound;
60 // Synthesize may fail if backend unavailable; we skip strict check in that case
61 yarp::dev::ReturnValue ret = speech->synthesize("test", sound);
62 CHECK((bool)ret); // for return_code::ok if backend reachable
63
64 CHECK(dd.close());
65 }
66
67 Network::setLocalMode(false);
68}
TEST_CASE("dev::voiceBoxSynthesizer_test", "[yarp::dev]")
bool view(T *&x)
Get an interface to the device driver.
A generic interface for speech synthesis.
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.
A mini-server for performing network communication in the background.
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
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.