TTS CancelledError when using long text
The problem
Using a long text with the Text-to-speech (TTS) action results in an asyncio.exceptions.CancelledError.
TTS integrations tested:
- Google Translate - fails
- ElevenLabs - works with Turbo v2.5, fails with multilingual v2 - see #123845
- OpenAI TTS (custom integration) - fails
What version of Home Assistant Core has the issue?
core-2025.1.2
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Container
Integration causing the issue
Google Translate text-to-speech
Link to integration documentation on our website
https://www.home-assistant.io/integrations/google_translate/
Diagnostics information
home-assistant_google_translate_2025-01-15T18-09-45.679Z.log
Example YAML snippet
action: tts.speak
data:
cache: false
media_player_entity_id: media_player.bedroom
message: >-
The concept of compiling the world's knowledge in a single location dates
back to the ancient Library of Alexandria and Library of Pergamum, but the
modern concept of a general-purpose, widely distributed, printed
encyclopedia originated with Denis Diderot and the 18th-century French
encyclopedists. The idea of using automated machinery beyond the printing
press to build a more useful encyclopedia can be traced to Paul Otlet's 1934
book Traité de Documentation. Otlet also founded the Mundaneum, an
institution dedicated to indexing the world's knowledge, in 1910. This
concept of a machine-assisted encyclopedia was further expanded in H. G.
Wells' book of essays World Brain (1938) and Vannevar Bush's future vision
of the microfilm-based Memex in his essay "As We May Think" (1945). Another
milestone was Ted Nelson's hypertext design Project Xanadu, which began in
1960. The use of volunteers was integral in making and maintaining
Wikipedia. However, even without the internet, huge complex projects of
similar nature had made use of volunteers. Specifically, the creation of the
Oxford English Dictionary was conceived with the speech at the London
Library, on Guy Fawkes Day, 5 November 1857, by Richard Chenevix Trench. It
took about 70 years to complete. Dr. Trench envisioned a grand new
dictionary of every word in the English language, and to be used
democratically and freely. According to author Simon Winchester, "The
undertaking of the scheme, he said, was beyond the ability of any one man.
To peruse all of English literature – and to comb the London and New York
newspapers and the most literate of the magazines and journals – must be
instead 'the combined action of many.' It would be necessary to recruit a
team – moreover
target:
entity_id: tts.google_translate_en_com
Anything in the logs that might be useful for us?
ERROR (MainThread) [homeassistant] Error doing job: Exception in callback SpeechManager._async_get_tts_audio.<locals>.handle_error() at /usr/src/homeassistant/homeassistant/components/tts/__init__.py:844 (None)
Traceback (most recent call last):
File "/usr/local/lib/python3.13/asyncio/events.py", line 89, in _run
self._context.run(self._callback, *self._args)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/tts/__init__.py", line 846, in handle_error
if audio_task.exception():
~~~~~~~~~~~~~~~~~~~~^^
File "/usr/src/homeassistant/homeassistant/components/tts/__init__.py", line 786, in get_tts_data
extension, data = await engine_instance.internal_async_get_tts_audio(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
message, language, options
^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/src/homeassistant/homeassistant/components/tts/__init__.py", line 492, in internal_async_get_tts_audio
return await self.async_get_tts_audio(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
message=message, language=language, options=options
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/src/homeassistant/homeassistant/components/tts/__init__.py", line 509, in async_get_tts_audio
return await self.hass.async_add_executor_job(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
partial(self.get_tts_audio, message, language, options=options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
asyncio.exceptions.CancelledError
Additional information
No response
Related #108666
I am also experiencing this with ElevenLabs Multilingual V2 voices. I am able to use the Flash or Turbo models, but the quality is significantly reduced.
same
2025-05-11 22:38:55.956 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback SpeechManager._async_get_tts_audio.<locals>.handle_error() at /usr/src/homeassistant/homeassistant/components/tts/__init__.py:844 (None)
Traceback (most recent call last):
File "/usr/local/lib/python3.13/asyncio/events.py", line 89, in _run
self._context.run(self._callback, *self._args)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/tts/__init__.py", line 846, in handle_error
if audio_task.exception():
~~~~~~~~~~~~~~~~~~~~^^
File "/usr/src/homeassistant/homeassistant/components/tts/__init__.py", line 806, in get_tts_data
data = await async_convert_audio(
^^^^^^^^^^^^^^^^^^^^^^^^^^
...<7 lines>...
)
^
File "/usr/src/homeassistant/homeassistant/components/tts/__init__.py", line 227, in async_convert_audio
return await hass.async_add_executor_job(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<9 lines>...
)
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.