Stream music or radio

Hi @all,

I’m pretty fresh with rhasspy. Yet I’ve got everything running and accomplished to stream a single wav sound. Is there a way to stream music? Like using an url from a radio station or from spotify.

I’ve thought about creating a spotify skill using their API to search for songs.

Thanks for any hints

EDIT: I’ve seen the answer of synesthesiam: Github Issue concerning stream continuously

I don’t get yet some basics:

  1. Do I need to convert the http stream to wav to output it using rhasspy?
  2. Will rhasspy still listen for his wakeword so I can stop playing music by saying “stop music” for example?
  3. Is he reffering to the audio input section in his answer? I guessed the audio output section is fitting for this use case. Am I wrong?

Maybe the easiest way is to use something like this: mopidy
Has anyone experiences?

Hi,
If there is noise (music) rhasspy will listen to the microphone poorly.
I use gesture recognition with SparkFun APDS9960, esp8266 (arduino) and mqtt, Placed on the table, simple and cheap
If I approach: I cut the sound I can speech :smile:
up: I increase the sound
down: I decrease the sound
left: wakeword
For music (radio, deezer …), I create a thread, with function stop, start …
Everything is possible.

Rhasspy cannot stream audio OUT from an url, it only streams audio OUT which is generated by the system.
That is, generated speech or the feedback sounds.

From the answer:
1: Rhasspy does not output any INPUT audio.
2: See (1)
3: Yes, for both questions :wink:

I use mopidy, work wells but no interaction with Rhasspy in my case (yet)
In my case, it is combined with a snapcast server and several clients for multiroom audio :slight_smile:

1 Like

Ok thanks so far guys. As soon as kaldi is working I’ll start experimenting.

I’ve got everything set up now. So I can start a radio stream using rhasspy.

@romkabouter how are you solving the issue, that mopidy can’t use the same audio output as rhasspy? Atm if I start my radio mopidy just tells me in his logs that:

ERROR 2020-04-12 16:44:30,229 [16810:MainThread] mopidy.audio.gst GStreamer error: Could not open audio device for playback. Device is being used by another application.

I know that rhasspy is blocking this but actually I would like to play the radio stream over the same speakers as rhasspy is talking to me.

Any hints on how to solve this?

I did not, but I think snapcast can be the answer.

Would you mind explaining what shall be change in case of using snapcast?

Btw do you mean this: Snapcast?

Yes, I meant snapcast :slight_smile:

Install a server somewhere (the same device as you have installed mopidy), Mopidy can pipe the output to the server.
You can use all sorts of devices as clients (multiroom audio).

Then, you can configure Rhasspy to output to MQTT. The part missing is a connection for listening to the MQTT stream and outputting it to to snapserver.
I do not know if something like that is already available.

1 Like

Thanks. I’ll look into it the next days.

I will try to and do this as well :slight_smile:
I have got Mopidy and snapserver running on a VM on proxmox, but I have not tried to use that same snapserver with Rhasspy

I’ve got rhasspy to set a german radio station (swr3) and start playing it over mopidy. What’s your approach? Playing local mp3 files?

I only play spotify at the moment

@romkabouter how is your progress?

I’ve opened a forums post at the mopidy community: https://discourse.mopidy.com/t/gstreamer-error/2481

Is the piping from mopidy to snapserver working in your case?

I’ve got another question to you. Is the setup as follows?

Like you said in a post above --> Snapserver and mopidy

I have a pi4 which is running rhasspy atm as well as mopidy and a snapserver. It’s not clear for me whether I need a snapclient as well or not? I think I don’t need one, because acutally the better approach would be to connect to the websocket api of the snapserver and get the stream from there and pipe it into the mqtt stream topic of rhasspy. What do you think?

Yesterday I’ve ran an snapclient on the console and the stream worked well. Except for the errors with stopping and actually correctly starting the stream using iris in mopidy.

I am partime schoolteacher now, so free time is sparse.

Piping works fine, I have mopidy and snapserver on the same machine.
You only need snapclients on the devices you want to play audio.

piping the snapserver into the MQTT stream might be a good idea, but I dont think the MQTT is a continues stream of bytes, but rather a stream of a lot of small wave files.
I will see if I can free up some time to try this as well :slight_smile:

Would you mind showing me your config of mopidy?
How do you pipe it atm and which mopidy version and snapcast are you using?

Ok, lets consider another setup (the one I am trying to do)

my server:
- mopidy player (from sources like youtube, spotiy etc)  -> /tmp/snapfifo -> snapcast server -> stream -> snapcast clients

my Rpi client with Rhaaspy:   
- rhasspy            ->
                         dmixed alsa device -> sound card
- snapcast client    ->

This is the config file at /etc/mopidy/mopidy.conf. I run a VM with debian stretch.
I have installed mopidy and snapcast

[core]
cache_dir = /var/cache/mopidy
config_dir = /etc/mopidy
data_dir = /var/lib/mopidy

[logging]
config_file = /etc/mopidy/logging.conf
debug_file = /var/log/mopidy/mopidy-debug.log

[file]
enabled = false

[local]
enabled = false
media_dir = /var/lib/mopidy/media

[m3u]
enabled = false
playlists_dir = /var/lib/mopidy/playlists

[http]
hostname = ::

[mpd]
enabled = true
hostname = ::

[spotify]
client_id = id
client_secret = secret
username = user
password = pass

[audio]
output = audioresample ! audio/x-raw,rate=48000,channels=2,format=S16LE ! audioconvert ! wavenc ! filesink location=/tmp/snapfifo

[lastfm]
enabled = false

The [audio] part is the one that pipe the output form mopidy to the /tmp/snapfifo, which is the snapserver.
I do not know if Mopidy can output to multiple channels, but if you want to have output on the machine Mopidy is running, you can use snapclient -h I think.
I do not use that right now.

My clients are a pi zero with a BT speaker and a pi3 with a speaker. The BT speaker is actually a ceiling lamp so I can play audio over that.

So what I need to do is find a way to make Rhasspy output to the pipe on the mopidy/snapserver device.
On thing I can think of is to use this little gem:
https://github.com/koenvervloesem/hermes-audio-server

I was developed to subscribe to a MQTT topic and output the audio.
It is probably not complete, but the idea is to create a piece of code subscribed to your Rhasspy MQTT out topic and pipe that stream to you snapserver.
This is 1 idea however, so there might be already some code which does it :slight_smile:

The idea of @litinoveweedle will work, but implies Rhasspy running on a different device.
One also being able to output audio. This is a problem if your Rhasspy is on a NUC or some other server. I currently have Rhasspy running as addon in Home Assistant

Thanks for your fast reply.

I see. Basically with hermes-audio-server you would run wakeword as well as actually all communication with rhasspy over this?

Advantage would be that rhasspy isn’t blocking the speaker in- and output all the time isn’t it?

Well, you might only have to run the hermes-audio-player to grab the MQTT stream from Rhasspy and pipe it to snapserver.
I do not think that software is currently capable, right @koan?

Well, I only created hermes-audio-server because Rhasspy was a big monolith then and I wanted a light piece of software to only process audio on a satellite. To be honest, I consider hermes-audio-server deprecated now that Rhasspy is modularized.

I don’t have any recent experience with snapcast or mopidy, so I’m not sure how you would use hermes-audio-server with it.