synesthesiam/homeassistant-satellite

Crash when sound files are non-existent

Closed this issue · 0 comments

homeassistant-satellite crashes when the awake/done sounds are non-existent. main.py should check for file existence and disable awake and/or done sound when either file could not be found. Since those files will not be used directly but rather later in the runtime, this should be checked right after parsing the args.

DEBUG:root:play: ['ffmpeg', '-i', '/venv/sounds/awake.wav', '-f', 'wav', '-ar', '22050', '-ac', '1', '-filter:a', 'volume=1.0', '-']
Playing raw data 'stdin' : Signed 16 bit Little Endian, Rate 22050 Hz, Mono
ERROR:__main__:Sound error in _playback_proc
Traceback (most recent call last):
  File "/usr/src/app/homeassistant_satellite/__main__.py", line 465, in _playback_proc
    play(item.media)
  File "/usr/src/app/homeassistant_satellite/snd.py", line 66, in play
    for chunk in chunks:
  File "/usr/src/app/homeassistant_satellite/snd.py", line 277, in media_to_chunks
    with wave.open(proc.stdout, "rb") as wav_file:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/wave.py", line 631, in open
    return Wave_read(f)
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/wave.py", line 283, in __init__
    self.initfp(f)
  File "/usr/local/lib/python3.11/wave.py", line 248, in initfp
    self._file = _Chunk(file, bigendian = 0)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/wave.py", line 114, in __init__
    raise EOFError
EOFError