From 324fb23f76a53fd6a7337fc6e2f265f7d874a710 Mon Sep 17 00:00:00 2001 From: Stijn Tintel Date: Mon, 26 Feb 2024 20:00:55 +0200 Subject: [PATCH] audio: increase HTTP stream timeout after send for TTS In commit af99de418c18 ("audio: reduce HTTP Stream timeout to 2s") we changed the HTTP Stream timeout to 2s so we can indicate early when we're not able to connect to WIS. Unfortunately ESP HTTP Client only has a single timeout value, and we now also abort the HTTP connection to WIS if TTS takes longer than 2s. We want to keep the timeout reasonably low, as having to wait for a TTS response for too long isn't great for UX, but 2s is too short for long TTS responses. Leave the initial timeout at 2s, but increase it to 10s on the HTTP_STREAM_POST_REQUEST event, which happens after the HTTP client sent header and body to WIS, but before fetching the response. --- main/audio.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main/audio.c b/main/audio.c index 955ed1ed..cb1b873a 100644 --- a/main/audio.c +++ b/main/audio.c @@ -195,6 +195,9 @@ static esp_err_t hdl_ev_hs_esp_audio(http_stream_event_msg_t *msg) esp_http_client_set_authtype(http, HTTP_AUTH_TYPE_BASIC); esp_http_client_set_timeout_ms(http, HTTP_STREAM_TIMEOUT_MS); break; + case HTTP_STREAM_POST_REQUEST: + esp_http_client_set_timeout_ms(http, HTTP_STREAM_TIMEOUT_MS_POST_REQUEST); + break; default: break; }