synesthesiam / rhasspy

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

[Audio Output] Using blue tooth speaker #250

Open Lex-talionis opened 3 years ago

Lex-talionis commented 3 years ago

Ive updated my pi so that it uses pulse_audio bluetooth to stream to the speaker which works by using this commands

paplay /tmp/h2g2.ogg

so all my audio now goes through there just fine when playing from any file source or on the web.

my profile settings for the sound output is as follows

"sounds": { "aplay": { "device": "pulse" }, "system": "aplay" },

When i go to the home page and try to make it speak some text it doesnt work and i get this error

AudioServerException: Command '['aplay', '-q', '-t', 'wav', '-D', 'pulse']' returned non-zero exit status 1.

and the logs looks like this

[ERROR:2020-07-19 16:42:03,694] rhasspyserver_hermes: Command '['aplay', '-q', '-t', 'wav', '-D', 'pulse']' returned non-zero exit status 1. Traceback (most recent call last): File "/usr/lib/rhasspy/.venv/lib/python3.7/site-packages/quart/app.py", line 1821, in full_dispatch_request result = await self.dispatch_request(request_context) File "/usr/lib/rhasspy/.venv/lib/python3.7/site-packages/quart/app.py", line 1869, in dispatch_request return await handler(**request_.view_args) File "/usr/lib/rhasspy/rhasspy-server-hermes/rhasspyserver_hermes/__main__.py", line 1609, in api_text_to_speech results = await asyncio.gather(*aws) File "/usr/lib/rhasspy/rhasspy-server-hermes/rhasspyserver_hermes/__main__.py", line 1595, in speak session_id=session_id, File "/usr/lib/rhasspy/rhasspy-server-hermes/rhasspyserver_hermes/__init__.py", line 596, in speak_sentence raise AudioServerException(play_response.error) rhasspyserver_hermes.AudioServerException: Command '['aplay', '-q', '-t', 'wav', '-D', 'pulse']' returned non-zero exit status 1. [ERROR:2020-07-19 16:42:03,692] rhasspyserver_hermes: AudioPlayError(error="Command '['aplay', '-q', '-t', 'wav', '-D', 'pulse']' returned non-zero exit status 1.", site_id='default', context='c55dbef3-4476-4c44-bded-de1212205ba0', session_id='') [DEBUG:2020-07-19 16:42:03,688] rhasspyserver_hermes: Handling TtsSayFinished (topic=hermes/tts/sayFinished, id=428de13a-4d5b-47ac-9092-61265ba26171) [DEBUG:2020-07-19 16:42:03,641] rhasspyserver_hermes: Handling AudioPlayError (topic=hermes/error/audioServer/play, id=428de13a-4d5b-47ac-9092-61265ba26171) [DEBUG:2020-07-19 16:42:03,590] rhasspyserver_hermes: Handling AudioPlayBytes (topic=hermes/audioServer/default/playBytes/c55dbef3-4476-4c44-bded-de1212205ba0, id=428de13a-4d5b-47ac-9092-61265ba26171) [DEBUG:2020-07-19 16:42:03,509] rhasspyserver_hermes: Publishing 119 bytes(s) to hermes/tts/say [DEBUG:2020-07-19 16:42:03,508] rhasspyserver_hermes: -> TtsSay(text='Hello Amy', site_id='default', lang=None, id='c55dbef3-4476-4c44-bded-de1212205ba0', session_id='') [DEBUG:2020-07-19 16:42:03,506] rhasspyserver_hermes: Subscribed to hermes/error/audioServer/play [DEBUG:2020-07-19 16:42:03,504] rhasspyserver_hermes: Subscribed to hermes/audioServer/default/playBytes/# [DEBUG:2020-07-19 16:42:03,503] rhasspyserver_hermes: Subscribed to hermes/error/tts [DEBUG:2020-07-19 16:42:03,501] rhasspyserver_hermes: Subscribed to hermes/tts/sayFinished

from what i can gather its trying to use aplay to play audio but really what i want is for it to use the command paplay instead as i know that works for streaming sound to the speaker.

ive seen in the docs that there is a command section for audio ouput like this

`"sounds": { "system": "command", "command": { "play_program": "/path/to/play/program", "play_arguments": [], "list_program": "/path/to/list/program", "list_arguments": [] } }

would i need to implement this in my profile and is so could someone hint at what it might be for paplay.

Thanks in advance

synesthesiam commented 3 years ago

I'd guess that you could just set play_program to /usr/bin/paplay and have it work. If you're running Rhasspy in Docker, though, this probably won't work right away.