YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
FakeSpeechTranscription.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
8#include <yarp/os/Log.h>
9#include <yarp/os/LogStream.h>
11
12#include <cstdio>
13#include <cstdlib>
14
15using namespace yarp::os;
16using namespace yarp::dev;
17
18namespace {
19YARP_LOG_COMPONENT(FAKE_SPEECHTR, "yarp.device.FakeSpeechTranscription")
20}
21
25
30
32{
33 if (!this->parseParams(config)) {return false;}
34
35 return true;
36}
37
39{
40 return true;
41}
42
44{
45 m_language=language;
46 yCInfo(FAKE_SPEECHTR) << "Language set to" << language;
47 return ReturnValue_ok;
48}
49
51{
52 language = m_language;
53 return ReturnValue_ok;
54}
55
56yarp::dev::ReturnValue FakeSpeechTranscription::transcribe(const yarp::sig::Sound& sound, std::string& transcription, double& score)
57{
58 if (sound.getSamples() == 0 ||
59 sound.getChannels() == 0)
60 {
61 yCError(FAKE_SPEECHTR) << "Invalid Sound sample received";
62 transcription = "";
63 score = 0.0;
64 return ReturnValue::return_code::return_value_error_method_failed;
65 }
66
67 transcription = "hello world";
68 score = 1.0;
69 return ReturnValue_ok;
70}
#define ReturnValue_ok
Definition ReturnValue.h:77
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
bool close() override
Close the DeviceDriver.
virtual yarp::dev::ReturnValue setLanguage(const std::string &language) override
Sets the language for speech transcription.
virtual yarp::dev::ReturnValue getLanguage(std::string &language) override
Gets the current language set for speech transcription.
virtual yarp::dev::ReturnValue transcribe(const yarp::sig::Sound &sound, std::string &transcription, double &score) override
Performs the speech transcription.
A mini-server for performing network communication in the background.
A base class for nested structures that can be searched.
Definition Searchable.h:31
Class for storing sounds See Audio in YARP for additional documentation on YARP audio.
Definition Sound.h:25
size_t getChannels() const
Get the number of channels of the sound.
Definition Sound.cpp:603
size_t getSamples() const
Get the number of samples contained in the sound.
Definition Sound.cpp:598
#define yCInfo(component,...)
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.