6#ifndef YARP_KOKOROSPEECHSYNTHESIZER_H
7#define YARP_KOKOROSPEECHSYNTHESIZER_H
19#if defined(__unix__) || defined(__APPLE__)
20# include <sys/types.h>
46 bool close()
override;
64 static std::string base64Encode(
const std::string& input);
65 static bool base64Decode(
const std::string& input, std::vector<unsigned char>& output);
66 static bool knownLanguage(
const std::string& language, std::string& kokoroCode);
67 static std::string defaultVoiceFor(
const std::string& kokoroCode);
69#if defined(__unix__) || defined(__APPLE__)
70 bool writeAll(
const std::string& data);
71 bool readLine(std::string& line,
int timeoutMs);
72 int m_workerInput{-1};
73 int m_workerOutput{-1};
74 pid_t m_workerPid{-1};
75 std::string m_readBuffer;
80 std::string m_pythonExecutable{
"python3"};
81 std::string m_workerScript;
82 std::string m_modelRepository;
84 std::string m_currentLanguage{
"en"};
85 std::string m_kokoroLanguage{
"a"};
86 std::string m_currentVoice{
"auto"};
87 bool m_voiceExplicit{
false};
88 double m_currentSpeed{1.0};
89 double m_currentPitch{0.0};
This class is the parameters parser for class KokoroSpeechSynthesizer.
YARP speech synthesizer backed by the Kokoro Python package.
yarp::dev::ReturnValue getLanguage(std::string &language) override
Gets the current language set for speech synthesis.
KokoroSpeechSynthesizer()=default
yarp::dev::ReturnValue setVoice(const std::string &voice_name="auto") override
Sets the voice set for speech synthesis.
yarp::dev::ReturnValue getAvailableVoices(yarp::sig::VectorOfString &voices) override
Returns the list of available voices for the currently set language.
KokoroSpeechSynthesizer & operator=(KokoroSpeechSynthesizer &&)=delete
yarp::dev::ReturnValue getVoice(std::string &voice_name) override
Gets the current voice set for speech synthesis.
yarp::dev::ReturnValue getPitch(double &pitch) override
Gets the current pitch set for speech synthesis.
yarp::dev::ReturnValue synthesize(const std::string &text, yarp::sig::Sound &sound) override
Performs the speech synthesis.
KokoroSpeechSynthesizer & operator=(const KokoroSpeechSynthesizer &)=delete
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
yarp::dev::ReturnValue setLanguage(const std::string &language="auto") override
Sets the language for speech synthesis.
KokoroSpeechSynthesizer(const KokoroSpeechSynthesizer &)=delete
yarp::dev::ReturnValue setSpeed(double speed=0) override
Sets the voice speed for speech synthesis.
yarp::dev::ReturnValue setPitch(double pitch) override
Sets the pitch for speech synthesis.
KokoroSpeechSynthesizer(KokoroSpeechSynthesizer &&)=delete
bool close() override
Close the DeviceDriver.
yarp::dev::ReturnValue getSpeed(double &speed) override
Gets the current voice speed.
~KokoroSpeechSynthesizer() override
Interface implemented by all device drivers.
A generic interface for speech synthesis.
A base class for nested structures that can be searched.
Class for storing sounds See Audio in YARP for additional documentation on YARP audio.