diff --git a/terminal/tts.c b/terminal/tts.c index 8a1fe4c..e95b115 100644 --- a/terminal/tts.c +++ b/terminal/tts.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include "base64.h" @@ -22,26 +22,24 @@ void tts_speak(char *Text) char *URL = (char *)malloc(strlen(B64Output) + strlen(g_IvonaURL)); sprintf(URL, g_IvonaURL, B64Output); printf("URL: %s\n", URL); + + if (!fork()) + { + printf("Forking...\n"); + char *CommandLine = malloc(strlen(URL) + 100); + sprintf(CommandLine, "curl -L -A Mozilla \"%s\" | mpg123 -2 -q -", URL); + printf("Cline: %s\n", CommandLine); + char *Arguments[4]; + Arguments[0] = "bash"; + Arguments[1] = "-c"; + Arguments[2] = CommandLine; + Arguments[3] = 0; + + char *Environment[1]; + Environment[0] = 0; + execve("/bin/bash", Arguments, Environment); + } - CURL *Curl; - CURLcode Result; - FILE *File; - - File = fopen("/tmp/hf-tts.mp3", "w"); - - Curl = curl_easy_init(); - curl_easy_setopt(Curl, CURLOPT_URL, URL); - curl_easy_setopt(Curl, CURLOPT_WRITEFUNCTION, tts_write_data); - curl_easy_setopt(Curl, CURLOPT_WRITEDATA, File); - curl_easy_setopt(Curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP|CURLPROTO_HTTPS); - curl_easy_setopt(Curl, CURLOPT_FOLLOWLOCATION, 1); - Result = curl_easy_perform(Curl); - curl_easy_cleanup(Curl); - - fclose(File); - - system("mpg123 -q -2 /tmp/hf-tts.mp3"); - free((void *)URL); free((void *)B64Output); }