YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
VoiceBoxSynthesizer.h
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#ifndef YARP_VOICEBOXSYNTHESIZER_H
7#define YARP_VOICEBOXSYNTHESIZER_H
8
9#include <chrono>
10#include <cstdint>
11#include <cstring>
12#include <stdexcept>
13#include <string>
14#include <thread>
15#include <vector>
16#include <map>
17
21
22
23using profilesList = std::vector<std::map<std::string, std::string>>;
24using profileMap = std::map<std::string, std::string>;
25
26
31{
32public:
36 VoiceBoxSynthesizer& operator=(const VoiceBoxSynthesizer&) = delete;
37 VoiceBoxSynthesizer& operator=(VoiceBoxSynthesizer&&) noexcept = delete;
38 ~VoiceBoxSynthesizer() override = default;
39
40 // DeviceDriver
41 bool open(yarp::os::Searchable& config) override;
42 bool close() override;
43
44 // ISpeechSynthesizer
45 yarp::dev::ReturnValue setLanguage(const std::string& language) override;
46 yarp::dev::ReturnValue getLanguage(std::string& language) override;
47 yarp::dev::ReturnValue setVoice(const std::string& voice_name) override;
48 yarp::dev::ReturnValue getVoice(std::string& voice_name) override;
49 yarp::dev::ReturnValue getAvailableVoices(yarp::sig::VectorOfString& voices) override;
50 yarp::dev::ReturnValue setSpeed(const double speed) override;
51 yarp::dev::ReturnValue getSpeed(double& speed) override;
52 yarp::dev::ReturnValue setPitch(const double pitch) override;
53 yarp::dev::ReturnValue getPitch(double& pitch) override;
54 yarp::dev::ReturnValue synthesize(const std::string& text, yarp::sig::Sound& sound) override;
55
56private:
57 std::string m_baseUrl = "http://localhost:17493";
58 std::string m_language = "en";
59 std::string m_region = "US";
60 profileMap m_profile;
61 double m_speed = 1.0;
62 double m_pitch = 1.0;
63};
64
65#endif // YARP_VOICEBOXSYNTHESIZER_H
std::map< std::string, std::string > profileMap
std::vector< std::map< std::string, std::string > > profilesList
This class is the parameters parser for class VoiceBoxSynthesizer.
yarp::dev::ReturnValue getPitch(double &pitch) override
Gets the current pitch set for speech synthesis.
yarp::dev::ReturnValue getLanguage(std::string &language) override
Gets the current language set for speech synthesis.
yarp::dev::ReturnValue setSpeed(const double speed) override
Sets the voice speed for speech synthesis.
yarp::dev::ReturnValue getSpeed(double &speed) override
Gets the current voice speed.
yarp::dev::ReturnValue getVoice(std::string &voice_name) override
Gets the current voice set for speech synthesis.
VoiceBoxSynthesizer(VoiceBoxSynthesizer &&) noexcept=delete
bool close() override
Close the DeviceDriver.
VoiceBoxSynthesizer(const VoiceBoxSynthesizer &)=delete
yarp::dev::ReturnValue setVoice(const std::string &voice_name) override
Sets the voice set for speech synthesis.
yarp::dev::ReturnValue setLanguage(const std::string &language) override
Sets the language for speech synthesis.
yarp::dev::ReturnValue getAvailableVoices(yarp::sig::VectorOfString &voices) override
Returns the list of available voices for the currently set language.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
yarp::dev::ReturnValue synthesize(const std::string &text, yarp::sig::Sound &sound) override
Performs the speech synthesis.
yarp::dev::ReturnValue setPitch(const double pitch) override
Sets the pitch for speech synthesis.
Interface implemented by all device drivers.
A generic interface for speech synthesis.
STL namespace.
The main, catch-all namespace for YARP.
Definition dirs.h:16