Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Piper TTS fails on long messages #3360

Closed
joshuazd opened this issue Dec 15, 2023 · 1 comment
Closed

Piper TTS fails on long messages #3360

joshuazd opened this issue Dec 15, 2023 · 1 comment
Labels

Comments

@joshuazd
Copy link

Describe the issue you are experiencing

When trying to using Piper to generate a long tts message (on Sonos speakers, in my case), the audio never plays on the speaker. This seems to happen at around 35 seconds, for me. Anything shorter than that works fine.

What type of installation are you running?

Home Assistant OS

Which operating system are you running on?

Home Assistant Operating System

Which add-on are you reporting an issue with?

Piper

What is the version of the add-on?

1.4.0

Steps to reproduce the issue

  1. Run a media_player.play_media service call with a long piper tts message, e.g.
service: media_player.play_media
target:
  entity_id: media_player.soundbar
data:
  media_content_type: music
  media_content_id: >-
    media-source:https://tts/tts.piper?message="This is a short message. This is a
    slightly longer message that takes longer to say. This is an even longer
    message where I'm going to keep talking for awhile so the length of the
    audio will increase. This is a 4th message to increase the length of the
    audio and I will keep talking and talking to make this longer. Lorem ipsum
    dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
    incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
    nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur."
  announce: false
  1. The message fails to play on the speaker.
    The same thing happens if I send announce: true, but with it set to false, I can see a message in the Sonos app that says "Unable to play '' - the connection to was lost"
    Shorter messages, which is pretty much anything under 35 seconds, always works, and anything longer seems to always fail.
    I have tried restarting various things (Home Assistant, the addon, etc.), clearing the TTS cache, and none of that has worked.

System Health information

System Information

version core-2023.12.3
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.11.6
os_name Linux
os_version 6.1.63-haos
arch x86_64
timezone America/Chicago
config_dir /config
Home Assistant Community Store
GitHub API ok
GitHub Content ok
GitHub Web ok
GitHub API Calls Remaining 4690
Installed Version 1.33.0
Stage running
Available Repositories 1352
Downloaded Repositories 48
Home Assistant Supervisor
host_os Home Assistant OS 11.2
update_channel stable
supervisor_version supervisor-2023.11.6
agent_version 1.6.0
docker_version 24.0.7
disk_total 62.3 GB
disk_used 30.7 GB
healthy true
supported true
board ova
supervisor_api ok
version_api ok
installed_addons Studio Code Server (5.14.2), Z-Wave JS UI (3.0.2), Advanced SSH & Web Terminal (17.0.0), Duck DNS (1.15.0), Dropbox Upload (1.3.0), MariaDB (2.6.1), phpMyAdmin (0.9.0), Mosquitto broker (6.4.0), Zigbee2MQTT (1.34.0-1), Home Assistant Google Drive Backup (0.112.1), Nginx Proxy Manager (0.12.3), ESPHome (2023.11.6), WireGuard (0.10.1), File editor (5.7.0), Piper (1.4.0), Whisper (1.0.0), openWakeWord (1.8.2)
Dashboards
dashboards 4
resources 29
views 23
mode storage
Recorder
oldest_recorder_run December 11, 2023 at 21:41
current_recorder_run December 15, 2023 at 10:30
estimated_db_size 8347.56 MiB
database_engine mysql
database_version 10.6.12
Spotify
api_endpoint_reachable ok

Anything in the Supervisor logs that might be useful for us?

No response

Anything in the add-on logs that might be useful for us?

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/wyoming/server.py", line 35, in run
    if not (await self.handle_event(event)):
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/wyoming_piper/handler.py", line 104, in handle_event
    await self.write_event(
  File "/usr/local/lib/python3.11/dist-packages/wyoming/server.py", line 26, in write_event
    await async_write_event(event, self.writer)
  File "/usr/local/lib/python3.11/dist-packages/wyoming/event.py", line 114, in async_write_event
    await writer.drain()
  File "/usr/lib/python3.11/asyncio/streams.py", line 378, in drain
    await self._protocol._drain_helper()
  File "/usr/lib/python3.11/asyncio/streams.py", line 167, in _drain_helper
    raise ConnectionResetError('Connection lost')
ConnectionResetError: Connection lost
ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-8439' coro=<AsyncEventHandler.run() done, defined at /usr/local/lib/python3.11/dist-packages/wyoming/server.py:28> exception=ConnectionResetError('Connection lost')>

Additional information

I see this in the Home Assistant Core log:

Logger: homeassistant
Source: components/wyoming/tts.py:125
First occurred: 10:34:04 (9 occurrences)
Last logged: 11:16:01

Error doing job: Exception in callback SpeechManager._async_get_tts_audio.<locals>.handle_error(<Task cancell...nit__.py:691>>) at /usr/src/homeassistant/homeassistant/components/tts/__init__.py:757
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/src/homeassistant/homeassistant/components/tts/__init__.py", line 759, in handle_error
    if audio_task.exception():
       ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/tts/__init__.py", line 701, in get_tts_data
    extension, data = await engine_instance.internal_async_get_tts_audio(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/tts/__init__.py", line 451, in internal_async_get_tts_audio
    return await self.async_get_tts_audio(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/wyoming/tts.py", line 125, in async_get_tts_audio
    event = await client.read_event()
            ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/wyoming/client.py", line 25, in read_event
    return await async_read_event(self._reader)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/wyoming/event.py", line 77, in async_read_event
    json_line = await reader.readline()
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/streams.py", line 548, in readline
    line = await self.readuntil(sep)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/streams.py", line 640, in readuntil
    await self._wait_for_data('readuntil')
  File "/usr/local/lib/python3.11/asyncio/streams.py", line 525, in _wait_for_data
    await self._waiter
asyncio.exceptions.CancelledError
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Jan 14, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant