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: Crash after any TTS call #3379

Closed
walking-octopus opened this issue Dec 31, 2023 · 8 comments
Closed

Piper: Crash after any TTS call #3379

walking-octopus opened this issue Dec 31, 2023 · 8 comments

Comments

@walking-octopus
Copy link

Describe the issue you are experiencing

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service piper: starting
s6-rc: info: service piper successfully started
s6-rc: info: service discovery: starting
INFO:wyoming_piper.download:Downloaded /data/en_US-lessac-medium.onnx.json (https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_US/lessac/medium/en_US-lessac-medium.onnx.json)
INFO:wyoming_piper.download:Downloaded /data/en_US-lessac-medium.onnx (https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_US/lessac/medium/en_US-lessac-medium.onnx)
INFO:__main__:Ready
[17:06:06] INFO: Successfully send discovery information to Home Assistant.
s6-rc: info: service discovery successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-9' coro=<AsyncEventHandler.run() done, defined at /usr/local/lib/python3.11/dist-packages/wyoming/server.py:28> exception=ConnectionResetError('Connection lost')>
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 38, in handle_event
    await self.write_event(self.wyoming_info_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-15' coro=<AsyncEventHandler.run() done, defined at /usr/local/lib/python3.11/dist-packages/wyoming/server.py:28> exception=ConnectionResetError(104, 'Connection reset by peer')>
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/wyoming/server.py", line 31, in run
    event = await async_read_event(self.reader)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/wyoming/event.py", line 62, in async_read_event
    json_line = await reader.readline()
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/streams.py", line 545, in readline
    line = await self.readuntil(sep)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/streams.py", line 637, in readuntil
    await self._wait_for_data('readuntil')
  File "/usr/lib/python3.11/asyncio/streams.py", line 522, in _wait_for_data
    await self._waiter
  File "/usr/lib/python3.11/asyncio/selector_events.py", line 995, in _read_ready__data_received
    data = self._sock.recv(self.max_size)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer
INFO:wyoming_piper.download:Downloaded /data/en_US-amy-low.onnx.json (https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_US/amy/low/en_US-amy-low.onnx.json)
INFO:wyoming_piper.download:Downloaded /data/en_US-amy-low.onnx (https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_US/amy/low/en_US-amy-low.onnx)
ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-28' coro=<AsyncEventHandler.run() done, defined at /usr/local/lib/python3.11/dist-packages/wyoming/server.py:28> exception=ConnectionResetError('Connection lost')>
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 38, in handle_event
    await self.write_event(self.wyoming_info_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-24' coro=<AsyncEventHandler.run() done, defined at /usr/local/lib/python3.11/dist-packages/wyoming/server.py:28> exception=FileNotFoundError(2, 'No such file or directory')>
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 98, in handle_event
    wav_file: wave.Wave_read = wave.open(output_path, "rb")
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/wave.py", line 630, in open
    return Wave_read(f)
           ^^^^^^^^^^^^
  File "/usr/lib/python3.11/wave.py", line 280, in __init__
    f = builtins.open(f, 'rb')
        ^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: ''

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. Install Piper
  2. Set up the integration.
  3. Play any audio.
  4. Observe the Piper server's logs

System Health information

## System Information

version | core-2023.12.4
-- | --
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.58-haos-raspi
arch | aarch64
timezone | Europe/Kiev
config_dir | /config

<details><summary>Home Assistant Cloud</summary>

logged_in | false
-- | --
can_reach_cert_server | ok
can_reach_cloud_auth | ok
can_reach_cloud | ok

</details>

<details><summary>Home Assistant Supervisor</summary>

host_os | Home Assistant OS 11.2
-- | --
update_channel | stable
supervisor_version | supervisor-2023.12.0
agent_version | 1.6.0
docker_version | 24.0.7
disk_total | 58.0 GB
disk_used | 10.9 GB
healthy | true
supported | true
board | rpi3-64
supervisor_api | ok
version_api | ok
installed_addons | Samba share (12.2.0), Mosquitto broker (6.4.0), Node-RED (16.0.2), SQLite Web (4.0.0), Terminal & SSH (9.8.1), File editor (5.7.0), JupyterLab (0.12.1), Piper (1.4.0)

</details>

<details><summary>Dashboards</summary>

dashboards | 1
-- | --
resources | 0
views | 1
mode | storage

</details>

<details><summary>Recorder</summary>

oldest_recorder_run | October 6, 2023 at 01:35
-- | --
current_recorder_run | December 31, 2023 at 16:42
estimated_db_size | 102.11 MiB
database_engine | sqlite
database_version | 3.41.2

</details>

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

Logger: homeassistant
Source: components/wyoming/tts.py:125
First occurred: 17:08:41 (1 occurrences)
Last logged: 17:08:41

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


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

_No response_

### Additional information

_No response_
@Juliafin
Copy link

Juliafin commented Jan 3, 2024

This is especially likely to happen when playing longer messages. This is currently preventing me (and others) from switching TTS engines to Piper (this does not happen with my marytts based mimic3 server).

@walking-octopus
Copy link
Author

For me, it happens on any message. This issue is new in this update, before working as expected.

Copy link

github-actions bot commented Feb 3, 2024

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 Feb 3, 2024
@llluis
Copy link

llluis commented Feb 5, 2024

File "/usr/local/lib/python3.11/dist-packages/wyoming_piper/handler.py", line 98, in handle_event
wav_file: wave.Wave_read = wave.open(output_path, "rb")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/wave.py", line 630, in open
return Wave_read(f)
^^^^^^^^^^^^
File "/usr/lib/python3.11/wave.py", line 280, in init
f = builtins.open(f, 'rb')
^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: ''

This seem the same error described here rhasspy/wyoming-piper#8

Piper is crashing when writing the resulting audio wav file, so the instruction to open it to continue is failing.

Wild guess, try to increase the parameter Option: max_piper_procs from 1 to 2.

@github-actions github-actions bot removed the stale label Feb 5, 2024
@valentinfrlch
Copy link

I tried increasing the number of processes to 2, does not fix the issue however. Piper only seems to work for shorter texts. As soon as the input gets a little longer I get this:

DEBUG:wyoming_piper.handler:Sent info
DEBUG:wyoming_piper.handler:/tmp/tmpc2t3vqfb/1708762474139810881.wav
ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-45' coro=<AsyncEventHandler.run() done, defined at /usr/local/lib/python3.11/dist-packages/wyoming/server.py:28> exception=ConnectionResetError('Connection lost')>
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

This is a different exception though.

Running on a Raspberry Pi 5 8GB
Piper addon version 1.4.0

@walking-octopus
Copy link
Author

Issue resolved for me. Piper 1.5.0, HA: 2024.3.0.

@ArifJSyed
Copy link

I tried increasing the number of processes to 2, does not fix the issue however. Piper only seems to work for shorter texts. As soon as the input gets a little longer I get this:

DEBUG:wyoming_piper.handler:Sent info
DEBUG:wyoming_piper.handler:/tmp/tmpc2t3vqfb/1708762474139810881.wav
ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-45' coro=<AsyncEventHandler.run() done, defined at /usr/local/lib/python3.11/dist-packages/wyoming/server.py:28> exception=ConnectionResetError('Connection lost')>
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

This is a different exception though.

Running on a Raspberry Pi 5 8GB Piper addon version 1.4.0

Did you manage to fix this? I have the same issue with the same hardware - I changed PSU+cable and its fine now.

@valentinfrlch
Copy link

Never tried again unfortunately @ArifJSyed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants