Stream music or radio

Well I have no problems at all using the play command of sox to play a song over command line.

Anyway how do you mean and publish to audio? As far as I understood that’s the part I need to do myself. rhasspy-speakers-cli-hermes isn’t capable of doing this or am I wrong?

I meant publish your audio to the playBytes topic.
The playBytes topic also gets the audio from your TextToSpeech, but you can publish wave files as well.

Huge huge thanks to @romkabouter. After hours of playing around with him it’s finally working.

Now it’s possible to hear rhasspy and music from mopidy at the same time.

For everyone who wants to reach the same here is my asound.conf located in /etc/asound.conf

asound.conf:

pcm.!default {
  type plug
  slave.pcm "ossmix"
}

pcm.ossmix {
    type dmix
    ipc_perm 0666
    ipc_key 1024 # must be unique!
    slave {
        pcm "hw:1,0"      # you cannot use a "plug" device here, darn.
        period_time 0
        period_size 1024 # must be power of 2
        buffer_size 8192  # dito. It
    }
    bindings {
        0 0 # from 0 => to 0
        1 1 # from 1 => to 1
    }
}

ctl.!default {
  type plug
}

Adjust the pcm “hw:1,0” line to your needs.

make sure the timer under /dev/snd has the correct rights. In case of errors run:

chmod a+wr /dev/snd/timer
enables every user to use aplay command

Next change the audio output inside rhasspy to mqtt/hermes and start rhasspy-speakers-cli-hermes using:

rhasspy-speakers-cli-hermes --play-command aplay

EDIT: for everyone who’s coming around this post! My setup is rhasspy 2.5 in docker on a pi4 with mopidy running as service on the pi itself.

3 Likes

Is that located inside the (Rhasspy?) docker container, or on the host?

on the host so in my case on the pi

In the end we had the following:

  • Mopidy playing music with config:

[audio]
output = alsasink device=default

  • Installed and running rhasspy-speakers-cli-hermes:
    https://github.com/rhasspy/rhasspy-speakers-cli-hermes
    The docker does not work, so build from source and run:
    rhasspy-speakers-cli-hermes --host 192.168.43.54 --username xxxx --password xxxx --site-id default --debug --play-command aplay

The host is the MQTT broker you have set Rhasspy to connect to, site-id is the id in the settings of Rhasspy

Both were working correct, Mopidy was playing through the speakers and rhasspy-speaker was also correctly playing.
The problem was mixing those, so rhasspy could play audio while mopidy was playing music.

Without modification, this would not would without modification because both need to use the audio device.
This can be done however with dmix type device

We have changed /etc/asound.conf on the Pi like Bozor indicated.
But there still was a permission error, which prevented mopdiy and the user pi (running rhasspy-speaker) to access the dmix device

We checjed the permissions with:

ls -la /dev/snd

Probably the output will be something like:

drwxr-xr-x 4 root root 180 Apr 24 14:53 .
drwxr-xr-x 16 root root 3860 Apr 24 14:54 …
drwxr-xr-x 2 root root 60 Apr 24 14:53 by-id
drwxr-xr-x 2 root root 60 Apr 24 14:53 by-path
crw-rw---- 1 root audio 116, 32 Apr 24 14:54 controlC1
crw-rw---- 1 root audio 116, 56 Apr 24 14:54 pcmC1D0c
crw-rw---- 1 root audio 116, 48 Apr 24 14:54 pcmC1D0p
crw-rw---- 1 root 18 116, 1 Apr 24 14:54 seq
crw-rw---- 1 root 18 116, 33 Apr 24 14:54 timer

The last line is the problem, the group audio does not have access to the timer.
Also, the user pi is normally not in the group audio (mopidy user is when following installation)
So, add pi to audio group with:

usermod pi -G audio

We gave permission to all users to /dev/snd/timer with:

chmod a+wr /dev/snd/timer

But I think only giving acces to the audio group would be better.

Bozo could now play music from Mopidy through the speakers and Rhasspy would also be able to play sound, mixed together!

Currently, I have taken it a step further and my output is not a speaker, but the snapcast server

2 Likes

Oh man. I’ve just rebooted today since my last session and the last step of our solution seems to be not persistent.

Any idea on how to fix this?

I had to run:

usermod pi -G audio

Afterwards everything worked again.

And a new funny fact is that docker seems to loose his permissions somehow.

I am following in here, but it seems over my head right now. I am trying to get away from my Echos. I am not getting MyCroft what I would like it to do, so I need a voice assistant that can play music (thru spotify etc…) and also communicate with HA and or NodeRed which it seems Rhasspy can do. I am worried about music streaming. Can you guys recap everything that you have done and is working well now? Thanks!!

To be honest, I’ve paused working actively on my Rhasspy atm. I plan to start again pretty soon.
Last time I had a lot of false positives with my wakeword so I thought waiting a bit more will solve the issue with a better wakeword engine coming up.

Sorry that I can’t help you atm.

Though happy to hear your progress.

Have you had a chance to look into this more? Seems like Rhasspy isnt setup to play music really.

Well I haven’t had spare time yet. Pretty busy on work ATM.
Did you have any success?

So I got it to stream music thru pulse audio and it wakes up fine actually. But the sound cracks. Alot on wifi and a little when connect with cable. Did your method with Mopidy crack?

I can’t remember any cracking during music or voice output.

The discussion above looks confusing. Is it pretty easy to try and set this up?

Thanks!
Joshua

Well it will take some time and probably some tweaks. But it’s not that hard if you have some basic Linux knowledge I would say.

Just wanted to share - this post led me down the road to success as well.
I wanted a combined system, and previously used custom handler in Rhasspy to play music.
The downside is that while playing, Rhasspy couldn’t wake… so I wanted to try and duplicate what you did here.

I have Rhasspy and Mopidy installed both in containers.
it took some learning to setup Mopidy correctly… but once I had that I was close.
I use Node-Red for automation - so I have accomplished this all by just doing automation…
Rhasspy controls Mopidy through Node-Red automation… and the wake work stops the music.

There were a few work arounds…

  1. Mopidy apparently can’t queue up from a playlist via it’s API… at least I couldn’t get it to work.
    To work around this, I pull the tracks form the playlist and then push them to the tracklist.add.

  2. Pausing Mopidy did not allow Rhasspy to use the speaker… had to stop playback.
    To fix this, I saved the current position in the song, and then seek it when I start playing again.

So far (1 day in) I am happy with what I have achieved! I’m sure I’ll find problems - but it has been an awesome adventure to replicate what I think is a complex setup from cloud type speakers. The last thing I haven’t finished is passing the single song to Mopidy… I the song name retrieval in Rhasspy already setup from previous work… just have get it passed to Mopidy.

Here is what it looks like in node red…

Cheers! and thanks for the inspiration!
DeadEnd

2 Likes

I have a pi 3B+ with respeaker 2 and alsa, no pulseaudio.
Rhasspy (satellite) runs as docker, squeezelite is installed on host.
Speech comes from the base rhasspy.
I want to hear rhasspy output while squeezelite is playing music.
Can i use this? Do i need rhasspy-speakers-cli-hermes?

Is Squeezelite + Rhasspy - Poor audio quality more relevant for me?
Unfortunately i dont know much about alsa and hope @rolyan_trauts, @GregoryWilson101 or someone else can help me with the right config.

For Home Assistant is an integration available to play TTS using LogitechMediaServer. But it works with the TTS integration.
I did not found a way to use rhasspy as TTS for Home Assistant other then by Hermes/MQTT.

Hi!
Using the setup like i menioned in my other topic you linked, I was able to get both speach and music simultaenously. I then had to use an automation to mute the audio when the rhasspy wake word was detected. I was never able to get the rhasspy docker to work with squeezelite.

Unfortuantely, due to the music playing the wake word very rarely worked. (And i mean rarely, i felt like a fool shouting “SNOW BOY” over anything but the quietest music playing).

I pivoted to using a physical button connected to a GPIO to activate rhasspy. And then eventually stoppd using rhasspy and used physical buttons for common music commands and a tablet for the Home Assistant GUI. Rhasspy is only as good as the hardware out there and the respeaker devices a tried were not replacement for a physical interface.

Haven’t had rhasspy set up for a while guys and my memory is rather dim but I would hazard a guess it could be to do with a sampling rate problem where many setup using hardware direct as in hw:0 which often is asking for trouble as if plughw:0 was used then there is a layer that will automatically resample and convert.

Snowboy never tried as I am not really sure why commercial cast off’s past sell buy have been adopted apart from they where there but there is a reason its no longer commercial as it was an early KW system and now not very good.
Hardware wise a mic is a mic its the underlying software that we are absent of even though you can make much better noise tolerant KWS than you have.
Pico Porcupine is prob the best almost non commercial as they do give totally free models to go at its just not open source.

The respeaker is as good a mic as any as my bugbear is it doesn’t matter at all and any more than 1 mic is totally pointless if it is not beeing processed by hardware or software dsp but there is no link up with the rhasspy system anyway.
You have an open mic with a KWS that is not very noise tolerant and to rub it in you have extra mics for no purpose at all apart from adding slight phase distortion due to the distance apart.

Your missing a whole load of software that I have tried in vain to raise many times that it is missing and lacking from the framework for such a long time and haven’t got the skills myself as it needs a modicum of C to do real time DSP as python really sucks so bad its pretty pointless trying, but obviously we only have a single good programmer who was Michael but only python based creating this initial audio processing hole.

The audio out is prob just some config somewhere but exactly what and where I am slightly out of the loop as got to the stage you guys are and thought yeah I will keep with the Google Nest Audio for now.
I am back playing with tensorflow as there is definately more dataset avail now and a KWS is not hard to accomplish but the interests of others lies elsewhere.

You might be interested in my approach with Jaco-MusicMaster. The setup works with docker and you can play songs from local file system or via youtube. To improve voice understanding, the skill automatically turns down the volume after wakeword detections, similar as @Gregory_Wilson’s concept.
Even though the skill is mainly intended for Jaco, you might be able to reuse some setup steps for a Rhasspy application.