Skip to content

Commit

Permalink
audio: increase HTTP stream timeout after send for TTS
Browse files Browse the repository at this point in the history
In commit af99de4 ("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.
  • Loading branch information
stintel authored and kristiankielhofner committed Feb 27, 2024
1 parent 3423b65 commit 324fb23
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions main/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 324fb23

Please sign in to comment.