synesthesiam / rhasspy

Rhasspy voice assistant for offline home automation
https://rhasspy.readthedocs.io
MIT License
942 stars 101 forks source link

No input/output devices since 2.4.19 #190

Closed basnijholt closed 4 years ago

basnijholt commented 4 years ago

I've just updated to 2.4.19 (because I needed the fix for https://github.com/synesthesiam/rhasspy/issues/178#event-3108321525), however, now I cannot select any input device in the Rhasspy add-on: image

In the Hassio hardware tab I do see the microphone: image

Any idea what happened?

basnijholt commented 4 years ago

Actually, rebooting the host made the Input and Output devices show up again.

However now, no devices are recognized inside the add-on:

export DOCKER=`sudo docker container ls | grep rhasspy | awk '{print $1}'`
sudo docker exec $DOCKER arecord -l

gives

arecord: device_list:270: no soundcards found...

Before this list also used to display my PS EYE 3 device: image

synesthesiam commented 4 years ago

Did Hass.io change some setting for how they expose audio devices?

felixmartens commented 4 years ago

Yes they did. According to my research they seperated the audio device exposure to a seperate docker container to allow multiple addons to access audio at same time. Seems there need to be some changes inside the addon to access audio again.

Just for notice: I have the exact same problem. Even after clean reinstall.

manju-rn commented 4 years ago

I have the similar problem. When I start the Rhasspy, i get the following error, hence not being able to speak anything to Rhasspy. I have tried both eSpeak and PyAudio and have the same problem since they both depend upon the alsa-utils

ALSA lib dlmisc.c:254:(snd1_dlobj_cache_get) Cannot open shared library /usr/lib/arm-linux-gnueabihf/alsa-lib/libasound_module_pcm_pulse.so
aplay: main:788: audio open error: No such device or address

Also I saw that the audio container in hassio is blocking the alsa. For example, if I stop the container and quickly run the aplay command in the SSH, it does run. I said "quickly" because I could run this only for a short duration as the watchdog in the hassio quick resets the audio container and the error reappears image

20-03-30 03:12:00 WARNING (MainThread) [supervisor.tasks] Watchdog found a problem with PulseAudio plugin!
20-03-30 03:12:00 INFO (MainThread) [supervisor.audio] Start Audio plugin
20-03-30 03:12:00 INFO (SyncWorker_15) [supervisor.docker.interface] Clean hassio_audio application
20-03-30 03:12:02 INFO (SyncWorker_15) [supervisor.docker.audio] Start Audio homeassistant/armv7-hassio-audio with version 9 - 
manju-rn commented 4 years ago

Here is the link for the HA Audio container HA Audio

felixmartens commented 4 years ago

Just for notice: a) I use the official RaspberryPi Image including the docker container. No manual containers at all. b) I reinstalled HassIO competly from scratch to sort out any update related error. c) I can choose the correct input and output Devices in Supervisor Tab Screenshot_2020-03-30-11-26-02-362_io homeassistant companion android But in WebUI for Rhasspy there are no input Devices detected: Screenshot_2020-03-30-11-26-16-156_org mozilla fenix

d) Perhaps this commit gives some useful hints as it migrates the Google Assistant Integration to tge new audio. Migrate google assistant to new audio (#1160) · home-assistant/hassio-addons@9000291 https://github.com/home-assistant/hassio-addons/commit/900029152383968239327ee4dbd0325673a7f7f3

And last but not least: Huge thanks for your tremendous work that enables me to have my own little voice recognition at Home!

manju-rn commented 4 years ago

Here are the details on the logs when I click 'Wake" in the Rhasspy console


DEBUG:WebrtcvadCommandListener:Will timeout in 30 second(s)
DEBUG:PocketsphinxWakeListener:listening -> loaded
DEBUG:WebrtcvadCommandListener:loaded -> listening
DEBUG:APlayAudioPlayer:['aplay', '-q', '/usr/share/rhasspy/etc/wav/beep_hi.wav']
DEBUG:PyAudioRecorder:started -> recording
[2020-03-30 09:55:11,577] xxx.xxx.xxx.xxx:xxxx GET /api/events/log 1.1 101 - 23232323
INFO:quart.serving:xxx.xxx.xxx.xxx:xxxx GET /api/events/log 1.1 101 - 23232323
ERROR:APlayAudioPlayer:on_receive
Traceback (most recent call last):
  File "/usr/share/rhasspy/rhasspy/actor.py", line 175, in on_receive
    self._state_method(message, sender)
  File "/usr/share/rhasspy/rhasspy/audio_player.py", line 67, in in_started
    self.play_file(message.wav_path)
  File "/usr/share/rhasspy/rhasspy/audio_player.py", line 90, in play_file
    subprocess.run(aplay_cmd, check=True)
  File "/usr/lib/python3.6/subprocess.py", line 423, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1295, in _execute_child
    restore_signals, start_new_session, preexec_fn)
OSError: [Errno 12] Cannot allocate memory
ERROR:PyAudioRecorder:to_recording
Traceback (most recent call last):
  File "/usr/share/rhasspy/rhasspy/audio_recorder.py", line 170, in to_recording
    frames_per_buffer=self.frames_per_buffer,
  File "/usr/local/lib/python3.6/dist-packages/pyaudio.py", line 750, in open
    stream = Stream(self, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/pyaudio.py", line 441, in __init__
    self._stream = pa.open(**arguments)
OSError: [Errno -9996] Invalid input device (no default output device)
DEBUG:PyAudioRecorder:recording -> started
ERROR:quart.serving:Error in ASGI Framework
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/hypercorn/asgi/wsproto.py", line 91, in handle_asgi_app
[2020-03-30 09:55:11,592] Error in ASGI Framework
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/hypercorn/asgi/wsproto.py", line 91, in handle_asgi_app
    await asgi_instance(self.asgi_receive, self.asgi_send)
  File "/usr/local/lib/python3.6/dist-packages/quart/asgi.py", line 106, in __call__
    await _cancel_tasks(pending)
  File "/usr/local/lib/python3.6/dist-packages/quart/asgi.py", line 189, in _cancel_tasks
    raise task.exception()
  File "/usr/local/lib/python3.6/dist-packages/quart/asgi.py", line 157, in handle_websocket
    'code': 1000,
  File "/usr/local/lib/python3.6/dist-packages/hypercorn/asgi/wsproto.py", line 149, in asgi_send
    await self.asend(CloseConnection(code=int(message["code"])))
  File "/usr/local/lib/python3.6/dist-packages/hypercorn/asyncio/wsproto.py", line 93, in asend
    self.write(self.connection.send(event))
  File "/usr/local/lib/python3.6/dist-packages/wsproto/__init__.py", line 64, in send
    data += self.connection.send(event)
  File "/usr/local/lib/python3.6/dist-packages/wsproto/connection.py", line 101, in send
    await asgi_instance(self.asgi_receive, self.asgi_send)
  File "/usr/local/lib/python3.6/dist-packages/quart/asgi.py", line 106, in __call__
    await _cancel_tasks(pending)
  File "/usr/local/lib/python3.6/dist-packages/quart/asgi.py", line 189, in _cancel_tasks
    raise task.exception()
  File "/usr/local/lib/python3.6/dist-packages/quart/asgi.py", line 157, in handle_websocket
    'code': 1000,
  File "/usr/local/lib/python3.6/dist-packages/hypercorn/asgi/wsproto.py", line 149, in asgi_send
    await self.asend(CloseConnection(code=int(message["code"])))
  File "/usr/local/lib/python3.6/dist-packages/hypercorn/asyncio/wsproto.py", line 93, in asend
    self.write(self.connection.send(event))
  File "/usr/local/lib/python3.6/dist-packages/wsproto/__init__.py", line 64, in send
    data += self.connection.send(event)
  File "/usr/local/lib/python3.6/dist-packages/wsproto/connection.py", line 101, in send
    "Connection cannot be closed in state %s" % self.state
wsproto.utilities.LocalProtocolError: Connection cannot be closed in state ConnectionState.CLOSED
    "Connection cannot be closed in state %s" % self.state
wsproto.utilities.LocalProtocolError: Connection cannot be closed in state ConnectionState.CLOSED```
manju-rn commented 4 years ago

[Resolved - Temporary] okay this is resolved temporarily by installing libasound2-plugins in the Rhasspy container. The solution was provided in the below community thread. However, requesting @synesthesiam to include it in the add-ons. Otherwise, each time this needs to be done when the add-ons is started

HA Community Rhasspy

felixmartens commented 4 years ago

Unfortunately this does not work for me as i use the HassIO Addon and thus i cannot login to the rhasspy Container.

synesthesiam commented 4 years ago

libasound2-plugins will be included in the 2.4.20 Docker image.