diff --git a/main/audio.c b/main/audio.c index 412dff769..aeb24c5a5 100644 --- a/main/audio.c +++ b/main/audio.c @@ -105,14 +105,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);