YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
fakePythonSpeechTranscription_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
7#include <yarp/os/Network.h>
11
12#include <catch2/catch_amalgamated.hpp>
13#include <harness.h>
14
15using namespace yarp::dev;
16using namespace yarp::os;
17
18TEST_CASE("dev::fakePythonSpeechTranscription", "[yarp::dev]")
19{
20 YARP_REQUIRE_PLUGIN("fakePythonSpeechTranscription", "device");
21
22 Network::setLocalMode(true);
23
24 SECTION("Checking fakePythonSpeechTranscription device")
25 {
28
29 //open the device
30 {
32 res.setDefaultContext("tests/fakePythonSpeechTranscription");
33 std::string filepath = res.findFileByName("Module.py");
34 std::string parentPath = filepath.substr(0, filepath.find_last_of("\\/"));
35
37 pdev_cfg.put("device", "fakePythonSpeechTranscription");
38 pdev_cfg.put("moduleName", "Module");
39 pdev_cfg.put("modulePath", parentPath);
40 pdev_cfg.put("className", "SpeechTranscriptor");
42 REQUIRE(ddfake.view(istr));
43 }
44
45 std::string lang = "eng";
46 CHECK(istr->getLanguage(lang)); // the default value initialized by the class is auto
47 CHECK(lang=="auto");
48
49 std::string new_lang = "eng";
50 CHECK(istr->setLanguage(new_lang));
51 CHECK(istr->getLanguage(lang));
52 CHECK(lang == "eng");
53
54 std::string transcript;
55 double score;
57 snd.resize(100, 2);
58 CHECK(istr->transcribe(snd,transcript, score));
59 CHECK(transcript=="hello world");
60 CHECK(score > 0.99);
61
62 //"Close all polydrivers and check"
63 {
66 }
67 }
68
69 Network::setLocalMode(false);
70}
A generic interface for speech transcription.
A container for a device driver.
Definition PolyDriver.h:23
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
Helper class for finding config files and other external resources.
bool setDefaultContext(const std::string &contextName)
Sets the context for the current ResourceFinder object.
std::string findFileByName(const std::string &name)
Find the full path to a file.
Class for storing sounds See Audio in YARP for additional documentation on YARP audio.
Definition Sound.h:25
void resize(size_t samples, size_t channels=1)
Set the sound size.
Definition Sound.cpp:270
TEST_CASE("dev::fakePythonSpeechTranscription", "[yarp::dev]")
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.