Skip to content

Commit

Permalink
Added default TTS timeout value of 30 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
nimroddolev committed Dec 17, 2024
1 parent d074c6d commit 4f08e1f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions custom_components/chime_tts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
QUEUE_TIMEOUT_KEY,
QUEUE_TIMEOUT_DEFAULT,
TTS_TIMEOUT_KEY,
TTS_TIMEOUT_DEFAULT,
SPOTIFY_PLATFORM,
TTS_PLATFORM_KEY,
DEFAULT_LANGUAGE_KEY,
Expand Down Expand Up @@ -410,7 +411,7 @@ async def async_update_configuration(config_entry: ConfigEntry, hass: HomeAssist
_data[TTS_PLATFORM_KEY] = options.get(TTS_PLATFORM_KEY, "")

# TTS timeout
_data[TTS_TIMEOUT_KEY] = options.get(TTS_TIMEOUT_KEY, None)
_data[TTS_TIMEOUT_KEY] = options.get(TTS_TIMEOUT_KEY, TTS_TIMEOUT_DEFAULT)

# Default language
_data[DEFAULT_LANGUAGE_KEY] = options.get(DEFAULT_LANGUAGE_KEY, None)
Expand Down Expand Up @@ -605,8 +606,7 @@ async def async_request_tts_audio(
audio_data = None
media_source_id = None
try:
timeout = _data.get(TTS_TIMEOUT_KEY, None)
_LOGGER.debug("```Generating TTS audio with a timeout of %ss", str(timeout or 0))
timeout = _data.get(TTS_TIMEOUT_KEY, TTS_TIMEOUT_DEFAULT)
media_source_id = await asyncio.wait_for(
asyncio.to_thread(
tts.media_source.generate_media_source_id,
Expand Down
3 changes: 2 additions & 1 deletion custom_components/chime_tts/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
QUEUE_TIMEOUT_KEY,
QUEUE_TIMEOUT_DEFAULT,
TTS_TIMEOUT_KEY,
TTS_TIMEOUT_DEFAULT,
TTS_PLATFORM_KEY,
DEFAULT_LANGUAGE_KEY,
DEFAULT_VOICE_KEY,
Expand Down Expand Up @@ -100,7 +101,7 @@ async def async_step_init(self, user_input):

self.data = {
QUEUE_TIMEOUT_KEY: self.get_data_key_value(QUEUE_TIMEOUT_KEY, user_input, QUEUE_TIMEOUT_DEFAULT),
TTS_TIMEOUT_KEY: self.get_data_key_value(TTS_TIMEOUT_KEY, user_input, ""),
TTS_TIMEOUT_KEY: self.get_data_key_value(TTS_TIMEOUT_KEY, user_input, TTS_TIMEOUT_DEFAULT),
TTS_PLATFORM_KEY: self.get_data_key_value(TTS_PLATFORM_KEY, user_input, ""),
DEFAULT_LANGUAGE_KEY: self.get_data_key_value(DEFAULT_LANGUAGE_KEY, user_input, ""),
DEFAULT_VOICE_KEY: self.get_data_key_value(DEFAULT_VOICE_KEY, user_input, ""),
Expand Down
1 change: 1 addition & 0 deletions custom_components/chime_tts/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
QUEUE_TIMEOUT_KEY = "queue_timeout"
QUEUE_TIMEOUT_DEFAULT = 60
TTS_TIMEOUT_KEY = "tts_timeout"
TTS_TIMEOUT_DEFAULT = 30
MAX_CONCURRENT_TASKS = 10
MAX_TIMEOUT = 600
QUEUE_PROCESSOR_SLEEP_TIME = 0.2
Expand Down

0 comments on commit 4f08e1f

Please sign in to comment.