6#ifndef _USE_MATH_DEFINES
7#define _USE_MATH_DEFINES
16#define DR_MP3_IMPLEMENTATION
89 return ReturnValue::return_code::return_value_error_generic;
93 return ReturnValue::return_code::return_value_error_generic;
135 return ReturnValue::return_code::return_value_error_generic;
138 std::string
payload =
"{\"model\": \"tts-1\", \"input\": \"" + _escapeJsonString(text) +
"\", \"voice\": \""+ m_voiceName +
"\"}";
159 return ReturnValue::return_code::return_value_error_generic;
168 return ReturnValue::return_code::return_value_error_generic;
194size_t TtsDevice::_writeCallback(
void *
contents,
size_t size,
size_t nmemb, std::vector<uint8_t> *output) {
200std::string TtsDevice::_escapeJsonString(
const std::string &input) {
201 std::ostringstream
ss;
202 for (
const auto &
c : input) {
204 case '\"':
ss <<
"\\\"";
break;
205 case '\\':
ss <<
"\\\\";
break;
206 case '\b':
ss <<
"\\b";
break;
207 case '\f':
ss <<
"\\f";
break;
208 case '\n':
ss <<
"\\n";
break;
209 case '\r':
ss <<
"\\r";
break;
210 case '\t':
ss <<
"\\t";
break;
212 if (
static_cast<unsigned char>(
c) < 0x20) {
213 ss <<
"\\u" << std::hex << std::setw(4) << std::setfill(
'0') << (
int)
c;
222bool TtsDevice::_voiceNameIsValid(
const std::string&
voice_name)
#define YARP_METHOD_NOT_YET_IMPLEMENTED()
const yarp::os::LogComponent & TTSDEVICE()
std::string m_ENVS_end_point_name
std::string m_ENVS_deployment_id_name
std::string m_ENVS_api_key_name
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
std::string m_ENVS_api_version_name
yarp::dev::ReturnValue setVoice(const std::string &voice_name="auto") override
Sets the voice set for speech synthesis.
bool close() override
Close the DeviceDriver.
yarp::dev::ReturnValue synthesize(const std::string &text, yarp::sig::Sound &sound) override
Performs the speech synthesis.
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.
yarp::dev::ReturnValue setPitch(const double pitch) override
Sets the pitch for speech synthesis.
yarp::dev::ReturnValue getVoice(std::string &voice_name) override
Gets the current voice set for speech synthesis.
yarp::dev::ReturnValue getLanguage(std::string &language) override
Gets the current language set for speech synthesis.
yarp::dev::ReturnValue getSpeed(double &speed) override
Gets the current voice speed.
yarp::dev::ReturnValue setSpeed(const double speed=0) override
Sets the voice speed for speech synthesis.
yarp::dev::ReturnValue getPitch(double &pitch) override
Gets the current pitch set for speech synthesis.
A mini-server for performing network communication in the background.
A base class for nested structures that can be searched.
Class for storing sounds See Audio in YARP for additional documentation on YARP audio.
void setFrequency(int freq)
Set the frequency of the sound (i.e.
void clear()
set all the samples to zero (silence)
void resize(size_t samples, size_t channels=1)
Set the sound size.
void set(audio_sample value, size_t sample, size_t channel=0)
drmp3_bool32 drmp3_init_memory(drmp3 *pMP3, const void *pData, size_t dataSize, const drmp3_allocation_callbacks *pAllocationCallbacks)
void drmp3_uninit(drmp3 *pMP3)
drmp3_uint64 drmp3_get_pcm_frame_count(drmp3 *pMP3)
drmp3_uint64 drmp3_read_pcm_frames_s16(drmp3 *pMP3, drmp3_uint64 framesToRead, drmp3_int16 *pBufferOut)
const std::vector< std::string > VOICES
ttsDevice: A yarp device for speech synthesis using azure openai APIs
#define yCInfo(component,...)
#define yCError(component,...)
#define yCWarning(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.