Unverified Commit 2a813431 authored by Wolle's avatar Wolle Committed by GitHub

Merge pull request #323 from ojaksch/master

New TTS provider MaryTTS
parents c33c4c01 1bb0ff7c
......@@ -787,6 +787,59 @@ bool Audio::connecttospeech(const char* speech, const char* lang){
return true;
}
//---------------------------------------------------------------------------------------------------------------------
bool Audio::connecttomarytts(const char* speech, const char* lang, const char* voice){
setDefaults();
char host[] = "mary.dfki.de";
char path[] = "/process";
int port = 59125;
uint16_t speechLen = strlen(speech);
uint16_t speechBuffLen = speechLen + 300;
memcpy(m_lastHost, speech, 256);
char* speechBuff = (char*)malloc(speechBuffLen);
if(!speechBuff) {log_e("out of memory"); return false;}
memcpy(speechBuff, speech, speechLen);
speechBuff[speechLen] = '\0';
urlencode(speechBuff, speechBuffLen);
char resp[strlen(speechBuff) + 200] = "";
strcat(resp, "GET ");
strcat(resp, path);
strcat(resp, "?INPUT_TEXT=");
strcat(resp, speechBuff);
strcat(resp, "&INPUT_TYPE=TEXT");
strcat(resp, "&OUTPUT_TYPE=AUDIO");
strcat(resp, "&AUDIO=WAVE_FILE");
strcat(resp, "&LOCALE=");
strcat(resp, lang);
strcat(resp, "&VOICE=");
strcat(resp, voice);
strcat(resp, " HTTP/1.1\r\n");
strcat(resp, "Host: ");
strcat(resp, host);
strcat(resp, "\r\n");
strcat(resp, "User-Agent: Mozilla/5.0 \r\n");
strcat(resp, "Accept-Encoding: identity\r\n");
strcat(resp, "Accept: text/html\r\n");
strcat(resp, "Connection: close\r\n\r\n");
free(speechBuff);
_client = static_cast<WiFiClient*>(&client);
if(!_client->connect(host, port)) {
log_e("Connection failed");
return false;
}
_client->print(resp);
m_f_webstream = true;
m_f_running = true;
m_f_ssl = false;
m_f_tts = true;
setDatamode(AUDIO_HEADER);
return true;
}
//---------------------------------------------------------------------------------------------------------------------
void Audio::urlencode(char* buff, uint16_t buffLen, bool spacesOnly) {
uint16_t len = strlen(buff);
......
......@@ -160,6 +160,7 @@ public:
void setBufsize(int rambuf_sz, int psrambuf_sz);
bool connecttohost(const char* host, const char* user = "", const char* pwd = "");
bool connecttospeech(const char* speech, const char* lang);
bool connecttomarytts(const char* speech, const char* lang, const char* voice);
bool connecttoFS(fs::FS &fs, const char* path, uint32_t resumeFilePos = 0);
bool connecttoSD(const char* path, uint32_t resumeFilePos = 0);
bool setFileLoop(bool input);//TEST loop
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment