YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
FakeSpeechSynthesizer.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_SPEECHSYN, "yarp.device.FakeSpeechSynthesizer")
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_SPEECHSYN) << "Language set to" << language;
47 return ReturnValue_ok;
48}
49
51{
52 language = m_language;
53 return ReturnValue_ok;
54}
55
57{
58 m_voice = voice;
59 yCInfo(FAKE_SPEECHSYN) << "Voice set to" << voice;
60 return ReturnValue_ok;
61}
62
64{
65 voice = m_voice;
66 return ReturnValue_ok;
67}
68
70{
71 m_speed = speed;
72 yCInfo(FAKE_SPEECHSYN) << "Speed set to" << speed;
73 return ReturnValue_ok;
74}
75
77{
78 speed = m_speed;
79 return ReturnValue_ok;
80}
81
83{
84 m_pitch = pitch;
85 yCInfo(FAKE_SPEECHSYN) << "Pitch set to" << pitch;
86 return ReturnValue_ok;
87}
88
90{
91 pitch = m_pitch;
92 return ReturnValue_ok;
93}
94
96{
97 if (text == "")
98 {
99 yCError(FAKE_SPEECHSYN) << "Text is empty";
100 return ReturnValue::return_code::return_value_error_method_failed;
101 }
102
103 sound.setFrequency(44100);
104 sound.resize(100,2);
105
106 return ReturnValue_ok;
107}
#define ReturnValue_ok
Definition ReturnValue.h:77
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
virtual yarp::dev::ReturnValue getVoice(std::string &voice) override
Gets the current voice set for speech synthesis.
virtual yarp::dev::ReturnValue setPitch(const double pitch) override
Sets the pitch for speech synthesis.
virtual yarp::dev::ReturnValue getPitch(double &voice) override
Gets the current pitch set for speech synthesis.
bool close() override
Close the DeviceDriver.
virtual yarp::dev::ReturnValue getLanguage(std::string &language) override
Gets the current language set for speech synthesis.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
virtual yarp::dev::ReturnValue synthesize(const std::string &text, yarp::sig::Sound &sound) override
Performs the speech synthesis.
virtual yarp::dev::ReturnValue setLanguage(const std::string &language) override
Sets the language for speech synthesis.
virtual yarp::dev::ReturnValue getSpeed(double &voice) override
Gets the current voice speed.
virtual yarp::dev::ReturnValue setSpeed(const double speed) override
Sets the voice speed for speech synthesis.
virtual yarp::dev::ReturnValue setVoice(const std::string &voice) override
Sets the voice set for speech synthesis.
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
void setFrequency(int freq)
Set the frequency of the sound (i.e.
Definition Sound.cpp:361
void resize(size_t samples, size_t channels=1)
Set the sound size.
Definition Sound.cpp:270
#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.