YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
KokoroSpeechSynthesizer Class Referencefinal

YARP speech synthesizer backed by the Kokoro Python package. More...

#include </home/runner/work/yarp-documentation/yarp-documentation/yarp/opt-modules/yarp-device-kokoro/src/devices/kokoroSpeechSynthesizer/KokoroSpeechSynthesizer.h>

+ Inheritance diagram for KokoroSpeechSynthesizer:

Public Member Functions

 KokoroSpeechSynthesizer ()=default
 
 KokoroSpeechSynthesizer (const KokoroSpeechSynthesizer &)=delete
 
 KokoroSpeechSynthesizer (KokoroSpeechSynthesizer &&)=delete
 
KokoroSpeechSynthesizer & operator= (const KokoroSpeechSynthesizer &)=delete
 
KokoroSpeechSynthesizer & operator= (KokoroSpeechSynthesizer &&)=delete
 
 ~KokoroSpeechSynthesizer () override
 
bool open (yarp::os::Searchable &config) override
 Open the DeviceDriver.
 
bool close () override
 Close the DeviceDriver.
 
yarp::dev::ReturnValue setLanguage (const std::string &language="auto") override
 Sets the language for speech synthesis.
 
yarp::dev::ReturnValue getLanguage (std::string &language) override
 Gets the current language set for speech synthesis.
 
yarp::dev::ReturnValue setVoice (const std::string &voice_name="auto") override
 Sets the voice set for speech synthesis.
 
yarp::dev::ReturnValue getVoice (std::string &voice_name) override
 Gets the current voice set for speech synthesis.
 
yarp::dev::ReturnValue getAvailableVoices (yarp::sig::VectorOfString &voices) override
 
yarp::dev::ReturnValue setSpeed (double speed=0) override
 Sets the voice speed for speech synthesis.
 
yarp::dev::ReturnValue getSpeed (double &speed) override
 Gets the current voice speed.
 
yarp::dev::ReturnValue setPitch (double pitch) override
 Sets the pitch 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.
 
- Public Member Functions inherited from yarp::dev::DeviceDriver
 DeviceDriver ()
 
 DeviceDriver (const DeviceDriver &other)=delete
 
 DeviceDriver (DeviceDriver &&other) noexcept=delete
 
DeviceDriver & operator= (const DeviceDriver &other)=delete
 
DeviceDriver & operator= (DeviceDriver &&other) noexcept=delete
 
virtual ~DeviceDriver ()
 
virtual std::string id () const
 Return the id assigned to the PolyDriver.
 
virtual void setId (const std::string &id)
 Set the id for this device.
 
template<class T >
bool view (T *&x)
 Get an interface to the device driver.
 
virtual DeviceDriver * getImplementation ()
 Some drivers are bureaucrats, pointing at others.
 
- Public Member Functions inherited from KokoroSpeechSynthesizer_ParamsParser
 KokoroSpeechSynthesizer_ParamsParser ()
 
 ~KokoroSpeechSynthesizer_ParamsParser () override=default
 
bool parseParams (const yarp::os::Searchable &config) override
 Parse the DeviceDriver parameters.
 
std::string getDeviceClassName () const override
 Get the name of the DeviceDriver class.
 
std::string getDeviceName () const override
 Get the name of the device (i.e.
 
std::string getDocumentationOfDeviceParams () const override
 Get the documentation of the DeviceDriver's parameters.
 
std::vector< std::string > getListOfParams () const override
 Return a list of all params used by the device.
 
bool getParamValue (const std::string &paramName, std::string &paramValue) const override
 Return the value (represented as a string) of the requested parameter.
 
std::string getConfiguration () const override
 Return the configuration of the device.
 
- Public Member Functions inherited from yarp::dev::IDeviceDriverParams
virtual ~IDeviceDriverParams ()
 
- Public Member Functions inherited from yarp::dev::ISpeechSynthesizer
virtual ~ISpeechSynthesizer ()
 

Additional Inherited Members

- Public Attributes inherited from KokoroSpeechSynthesizer_ParamsParser
const std::string m_device_classname = {"KokoroSpeechSynthesizer"}
 
const std::string m_device_name = {"kokoroSpeechSynthesizer"}
 
bool m_parser_is_strict = false
 
const parser_version_type m_parser_version = {}
 
std::string m_provided_configuration
 
const std::string m_python_executable_defaultValue = {"python3"}
 
const std::string m_worker_script_defaultValue = {""}
 
const std::string m_model_repository_defaultValue = {"hexgrad/Kokoro-82M"}
 
const std::string m_torch_device_defaultValue = {""}
 
const std::string m_language_defaultValue = {"en"}
 
const std::string m_voice_defaultValue = {"auto"}
 
const std::string m_speed_defaultValue = {"1"}
 
const std::string m_pitch_defaultValue = {"0"}
 
std::string m_python_executable = {"python3"}
 
std::string m_worker_script = {}
 
std::string m_model_repository = {"hexgrad/Kokoro-82M"}
 
std::string m_torch_device = {}
 
std::string m_language = {"en"}
 
std::string m_voice = {"auto"}
 
double m_speed = {1}
 
double m_pitch = {0}
 

Detailed Description

YARP speech synthesizer backed by the Kokoro Python package.

The plugin keeps a small Python worker alive and communicates with it through stdin/stdout. This avoids embedding Python in the YARP process while still keeping the Kokoro model loaded between synthesis requests.

Definition at line 32 of file KokoroSpeechSynthesizer.h.

Constructor & Destructor Documentation

◆ KokoroSpeechSynthesizer() [1/3]

KokoroSpeechSynthesizer::KokoroSpeechSynthesizer ( )
default

◆ KokoroSpeechSynthesizer() [2/3]

KokoroSpeechSynthesizer::KokoroSpeechSynthesizer ( const KokoroSpeechSynthesizer &  )
delete

◆ KokoroSpeechSynthesizer() [3/3]

KokoroSpeechSynthesizer::KokoroSpeechSynthesizer ( KokoroSpeechSynthesizer &&  )
delete

◆ ~KokoroSpeechSynthesizer()

KokoroSpeechSynthesizer::~KokoroSpeechSynthesizer ( )
override

Definition at line 132 of file KokoroSpeechSynthesizer.cpp.

Member Function Documentation

◆ close()

bool KokoroSpeechSynthesizer::close ( )
overridevirtual

Close the DeviceDriver.

Returns
true/false on success/failure.

Reimplemented from yarp::dev::DeviceDriver.

Definition at line 185 of file KokoroSpeechSynthesizer.cpp.

◆ getAvailableVoices()

yarp::dev::ReturnValue KokoroSpeechSynthesizer::getAvailableVoices ( yarp::sig::VectorOfString &  voices)
override

Definition at line 558 of file KokoroSpeechSynthesizer.cpp.

◆ getLanguage()

yarp::dev::ReturnValue KokoroSpeechSynthesizer::getLanguage ( std::string &  language)
overridevirtual

Gets the current language set for speech synthesis.

Parameters
languagethe returned string (code) representing the speech language (e.g. ita, eng...). Default value is "auto".
Returns
a ReturnValue, convertible to true/false

Implements yarp::dev::ISpeechSynthesizer.

Definition at line 533 of file KokoroSpeechSynthesizer.cpp.

◆ getPitch()

yarp::dev::ReturnValue KokoroSpeechSynthesizer::getPitch ( double &  voice)
overridevirtual

Gets the current pitch set for speech synthesis.

Parameters
pitchthe current voice pitch.
Returns
a ReturnValue, convertible to true/false

Implements yarp::dev::ISpeechSynthesizer.

Definition at line 599 of file KokoroSpeechSynthesizer.cpp.

◆ getSpeed()

yarp::dev::ReturnValue KokoroSpeechSynthesizer::getSpeed ( double &  speed)
overridevirtual

Gets the current voice speed.

Parameters
speedthe current voice speed.
Returns
a ReturnValue, convertible to true/false

Implements yarp::dev::ISpeechSynthesizer.

Definition at line 580 of file KokoroSpeechSynthesizer.cpp.

◆ getVoice()

yarp::dev::ReturnValue KokoroSpeechSynthesizer::getVoice ( std::string &  voice_name)
overridevirtual

Gets the current voice set for speech synthesis.

Parameters
voice_namethe currently used voice (device dependent).
Returns
a ReturnValue, convertible to true/false

Implements yarp::dev::ISpeechSynthesizer.

Definition at line 551 of file KokoroSpeechSynthesizer.cpp.

◆ open()

bool KokoroSpeechSynthesizer::open ( yarp::os::Searchable &  config)
overridevirtual

Open the DeviceDriver.

Parameters
configis a list of parameters for the device. Which parameters are effective for your device can vary. If there is no example for your device, you can run the "yarpdev" program with the verbose flag set to probe what parameters the device is checking. If that fails too, you'll need to read the source code (please nag one of the yarp developers to add documentation for your device).
Returns
true/false upon success/failure

Reimplemented from yarp::dev::DeviceDriver.

Definition at line 137 of file KokoroSpeechSynthesizer.cpp.

◆ operator=() [1/2]

KokoroSpeechSynthesizer & KokoroSpeechSynthesizer::operator= ( const KokoroSpeechSynthesizer &  )
delete

◆ operator=() [2/2]

KokoroSpeechSynthesizer & KokoroSpeechSynthesizer::operator= ( KokoroSpeechSynthesizer &&  )
delete

◆ setLanguage()

yarp::dev::ReturnValue KokoroSpeechSynthesizer::setLanguage ( const std::string &  language = "auto")
overridevirtual

Sets the language for speech synthesis.

Parameters
languagea string (code) representing the speech language (e.g. ita, eng...). Default value is "auto".
Returns
a ReturnValue, convertible to true/false

Implements yarp::dev::ISpeechSynthesizer.

Definition at line 517 of file KokoroSpeechSynthesizer.cpp.

◆ setPitch()

yarp::dev::ReturnValue KokoroSpeechSynthesizer::setPitch ( double  pitch)
overridevirtual

Sets the pitch for speech synthesis.

Parameters
pitchthe voice pitch.
Returns
a ReturnValue, convertible to true/false

Implements yarp::dev::ISpeechSynthesizer.

Definition at line 587 of file KokoroSpeechSynthesizer.cpp.

◆ setSpeed()

yarp::dev::ReturnValue KokoroSpeechSynthesizer::setSpeed ( double  speed = 0)
overridevirtual

Sets the voice speed for speech synthesis.

Parameters
speedthe voice speed.
Returns
a ReturnValue, convertible to true/false

Implements yarp::dev::ISpeechSynthesizer.

Definition at line 569 of file KokoroSpeechSynthesizer.cpp.

◆ setVoice()

yarp::dev::ReturnValue KokoroSpeechSynthesizer::setVoice ( const std::string &  voice_name = "auto")
overridevirtual

Sets the voice set for speech synthesis.

Parameters
voice_namethe name of of the voice (device dependent).
Returns
a ReturnValue, convertible to true/false

Implements yarp::dev::ISpeechSynthesizer.

Definition at line 540 of file KokoroSpeechSynthesizer.cpp.

◆ synthesize()

yarp::dev::ReturnValue KokoroSpeechSynthesizer::synthesize ( const std::string &  text,
yarp::sig::Sound &  sound 
)
overridevirtual

Performs the speech synthesis.

Parameters
textthe text to synthesize
soundthe synthesized audio stream
Returns
a ReturnValue, convertible to true/false

Implements yarp::dev::ISpeechSynthesizer.

Definition at line 606 of file KokoroSpeechSynthesizer.cpp.


The documentation for this class was generated from the following files: