19 YARP_LOG_COMPONENT(KokoroSpeechSynthesizerParamsCOMPONENT,
"yarp.device.KokoroSpeechSynthesizer")
30 std::vector<std::string> params;
31 params.push_back(
"python_executable");
32 params.push_back(
"worker_script");
33 params.push_back(
"model_repository");
34 params.push_back(
"torch_device");
35 params.push_back(
"language");
36 params.push_back(
"voice");
37 params.push_back(
"speed");
38 params.push_back(
"pitch");
45 if (paramName ==
"python_executable")
50 if (paramName ==
"worker_script")
55 if (paramName ==
"model_repository")
60 if (paramName ==
"torch_device")
65 if (paramName ==
"language")
70 if (paramName ==
"voice")
75 if (paramName ==
"speed")
77 paramValue = std::to_string(
m_speed);
80 if (paramName ==
"pitch")
82 paramValue = std::to_string(
m_pitch);
86 yError() <<
"parameter '" << paramName <<
"' was not found";
105 if (config.
check(
"help"))
114 if (config.
check(
"python_executable"))
121 yCInfo(KokoroSpeechSynthesizerParamsCOMPONENT) <<
"Parameter 'python_executable' using DEFAULT value:" <<
m_python_executable;
123 prop_check.
unput(
"python_executable");
128 if (config.
check(
"worker_script"))
131 yCInfo(KokoroSpeechSynthesizerParamsCOMPONENT) <<
"Parameter 'worker_script' using value:" <<
m_worker_script;
135 yCInfo(KokoroSpeechSynthesizerParamsCOMPONENT) <<
"Parameter 'worker_script' using DEFAULT value:" <<
m_worker_script;
137 prop_check.
unput(
"worker_script");
142 if (config.
check(
"model_repository"))
145 yCInfo(KokoroSpeechSynthesizerParamsCOMPONENT) <<
"Parameter 'model_repository' using value:" <<
m_model_repository;
149 yCInfo(KokoroSpeechSynthesizerParamsCOMPONENT) <<
"Parameter 'model_repository' using DEFAULT value:" <<
m_model_repository;
151 prop_check.
unput(
"model_repository");
156 if (config.
check(
"torch_device"))
159 yCInfo(KokoroSpeechSynthesizerParamsCOMPONENT) <<
"Parameter 'torch_device' using value:" <<
m_torch_device;
163 yCInfo(KokoroSpeechSynthesizerParamsCOMPONENT) <<
"Parameter 'torch_device' using DEFAULT value:" <<
m_torch_device;
165 prop_check.
unput(
"torch_device");
170 if (config.
check(
"language"))
173 yCInfo(KokoroSpeechSynthesizerParamsCOMPONENT) <<
"Parameter 'language' using value:" <<
m_language;
177 yCInfo(KokoroSpeechSynthesizerParamsCOMPONENT) <<
"Parameter 'language' using DEFAULT value:" <<
m_language;
179 prop_check.
unput(
"language");
184 if (config.
check(
"voice"))
187 yCInfo(KokoroSpeechSynthesizerParamsCOMPONENT) <<
"Parameter 'voice' using value:" <<
m_voice;
191 yCInfo(KokoroSpeechSynthesizerParamsCOMPONENT) <<
"Parameter 'voice' using DEFAULT value:" <<
m_voice;
193 prop_check.
unput(
"voice");
198 if (config.
check(
"speed"))
201 yCInfo(KokoroSpeechSynthesizerParamsCOMPONENT) <<
"Parameter 'speed' using value:" <<
m_speed;
205 yCInfo(KokoroSpeechSynthesizerParamsCOMPONENT) <<
"Parameter 'speed' using DEFAULT value:" <<
m_speed;
207 prop_check.
unput(
"speed");
212 if (config.
check(
"pitch"))
215 yCInfo(KokoroSpeechSynthesizerParamsCOMPONENT) <<
"Parameter 'pitch' using value:" <<
m_pitch;
219 yCInfo(KokoroSpeechSynthesizerParamsCOMPONENT) <<
"Parameter 'pitch' using DEFAULT value:" <<
m_pitch;
221 prop_check.
unput(
"pitch");
256 doc = doc + std::string(
"\n=============================================\n");
257 doc = doc + std::string(
"This is the help for device: KokoroSpeechSynthesizer\n");
258 doc = doc + std::string(
"\n");
259 doc = doc + std::string(
"This is the list of the parameters accepted by the device:\n");
260 doc = doc + std::string(
"'python_executable': Python interpreter containing the kokoro package.\n");
261 doc = doc + std::string(
"'worker_script': Path to kokoro_worker.py. If omitted, the build or installed worker is used.\n");
262 doc = doc + std::string(
"'model_repository': Hugging Face model repository used by Kokoro.\n");
263 doc = doc + std::string(
"'torch_device': PyTorch execution device, for example cpu or cuda. The empty value lets PyTorch/Kokoro choose automatically.\n");
264 doc = doc + std::string(
"'language': Speech language: en, en-gb, es, fr, hi, it, ja, pt-br, zh, or a Kokoro language code.\n");
265 doc = doc + std::string(
"'voice': Kokoro voice name, for example af_heart or bf_emma.\n");
266 doc = doc + std::string(
"'speed': Speech speed in the range (0, 4].\n");
267 doc = doc + std::string(
"'pitch': Stored for ISpeechSynthesizer compatibility. Kokoro currently does not apply pitch.\n");
268 doc = doc + std::string(
"\n");
269 doc = doc + std::string(
"Here are some examples of invocation command with yarpdev, with all params:\n");
270 doc = doc +
" yarpdev --device kokoroSpeechSynthesizer --python_executable python3 --worker_script <optional_value> --model_repository hexgrad/Kokoro-82M --torch_device <optional_value> --language en --voice auto --speed 1 --pitch 0\n";
271 doc = doc + std::string(
"Using only mandatory params:\n");
272 doc = doc +
" yarpdev --device kokoroSpeechSynthesizer\n";
273 doc = doc + std::string(
"=============================================\n\n");
return doc;
std::string m_python_executable
std::string getDocumentationOfDeviceParams() const override
Get the documentation of the DeviceDriver's parameters.
bool getParamValue(const std::string ¶mName, std::string ¶mValue) const override
Return the value (represented as a string) of the requested parameter.
std::vector< std::string > getListOfParams() const override
Return a list of all params used by the device.
std::string m_worker_script
std::string getConfiguration() const override
Return the configuration of the device.
KokoroSpeechSynthesizer_ParamsParser()
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
std::string m_torch_device
std::string m_model_repository
std::string m_provided_configuration
A class for storing options and configuration information.
void unput(const std::string &key)
Remove the association from the given key to a value, if present.
A base class for nested structures that can be searched.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
#define yCInfo(component,...)
#define YARP_LOG_COMPONENT(name,...)