From 0add33640559a74acb46869e467ab5b49b66e500 Mon Sep 17 00:00:00 2001 From: Stijn Tintel Date: Wed, 15 Nov 2023 21:50:59 +0200 Subject: [PATCH] audio: support wis_tts_url_v2 in config To have more flexibility with the new Coqui TTS backend, we're going to construct the TTS URL in WAS before sending it to Willow. We will support both the old and the new way for a while, both in Willow and WAS, so that old Willow versions will work with new WAS versions, and new Willow version will work with old WAS versions. --- main/audio.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/main/audio.c b/main/audio.c index 15129122..3ecfc93d 100644 --- a/main/audio.c +++ b/main/audio.c @@ -99,14 +99,26 @@ void play_audio_ok(void *data) static void play_audio_wis_tts(void *data) { + char *url = NULL; + char *wis_tts_url = NULL; + if (data == NULL) { ESP_LOGW(TAG, "called play_audio_wis_tts with NULL data"); return; } - char *wis_tts_url = config_get_char("wis_tts_url", DEFAULT_WIS_TTS_URL); - int len_url = strlen(wis_tts_url) + strlen(WIS_URL_TTS_ARG) + strlen((char *)data) + 1; - char *url = calloc(sizeof(char), len_url); - snprintf(url, len_url, "%s%s%s", wis_tts_url, WIS_URL_TTS_ARG, (char *)data); + + wis_tts_url = config_get_char("wis_tts_url_v2", NULL); + if (wis_tts_url != NULL) { + int len_url = strlen(wis_tts_url) + strlen((char *)data) + 1; + url = calloc(sizeof(char), len_url); + snprintf(url, len_url, "%s%s", wis_tts_url, (char *)data); + } else { + wis_tts_url = config_get_char("wis_tts_url", DEFAULT_WIS_TTS_URL); + int len_url = strlen(wis_tts_url) + strlen(WIS_URL_TTS_ARG) + strlen((char *)data) + 1; + url = calloc(sizeof(char), len_url); + snprintf(url, len_url, "%s%s%s", wis_tts_url, WIS_URL_TTS_ARG, (char *)data); + } + free(wis_tts_url); gpio_set_level(get_pa_enable_gpio(), 1); ESP_LOGI(TAG, "Using WIS TTS URL '%s'", url);