Skip to content

Commit

Permalink
audio: reduce HTTP Stream timeout to 2s
Browse files Browse the repository at this point in the history
Reduce default HTTP stream timeout from 30s to 2s. Letting a user wait
longer for a failure on a voice command or TTS response is terrible UX.
  • Loading branch information
stintel committed Nov 29, 2023
1 parent b18264e commit af99de4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions main/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@
#define DEFAULT_WIS_TTS_URL "https://infer.tovera.io/api/tts"
#define DEFAULT_WIS_URL "https://infer.tovera.io/api/willow"

#define MULTINET_TWDT 30
#define STR_WAKE_LEN 25
#define WIS_URL_TTS_ARG "?format=WAV&speaker=CLB&text="
#define HTTP_STREAM_TIMEOUT_MS 2 * 1000
#define MULTINET_TWDT 30
#define STR_WAKE_LEN 25
#define WIS_URL_TTS_ARG "?format=WAV&speaker=CLB&text="

QueueHandle_t q_ea, q_rec;
audio_hal_handle_t hdl_aha = NULL, hdl_ahc = NULL;
Expand Down Expand Up @@ -157,6 +158,7 @@ static esp_err_t hdl_ev_hs_esp_audio(http_stream_event_msg_t *msg)
switch (msg->event_id) {
case HTTP_STREAM_PRE_REQUEST:
esp_http_client_set_authtype(http, HTTP_AUTH_TYPE_BASIC);
esp_http_client_set_timeout_ms(http, HTTP_STREAM_TIMEOUT_MS);
break;
default:
break;
Expand Down Expand Up @@ -442,6 +444,7 @@ static esp_err_t hdl_ev_hs_to_api(http_stream_event_msg_t *msg)
ESP_LOGI(TAG, "WIS HTTP client starting stream, waiting for end of speech");
esp_http_client_set_authtype(http, HTTP_AUTH_TYPE_BASIC);
esp_http_client_set_method(http, HTTP_METHOD_POST);
esp_http_client_set_timeout_ms(http, HTTP_STREAM_TIMEOUT_MS);
char *audio_codec = config_get_char("audio_codec", DEFAULT_AUDIO_CODEC);
char dat[10] = {0};
snprintf(dat, sizeof(dat), "%d", 16000);
Expand Down

0 comments on commit af99de4

Please sign in to comment.