Mycroft Community Forum

Mycroft and Squeezelite

For quite a while I am running a multi-room audiosystem (LMS with squeezelite on a few Raspis each with USB-Soundcard and speaker), all merged with my OpenHAB - and I really like it. The next step for me is to integrate Mycroft into this. So, my plan is to simply add microphones to the existing RasPis + speaker and run mycroft + squeezelite on them and have Mycroft in all of my rooms.

Technically I thought it might be wise to first install mycroft using the PiCroft image on the RasPi, apt-get install squeezelite and be done. But: No matter how I try to specify the squeezelite -o - while running squeezelite (which works fine) I cannot get Mycroft to talk to me. Once I kill squeezelite again, some stacked messages from Mycroft come through. I have read a bit about problems with dmix on RasPi, but to be honest I am technically quite a noob and don’t really understand what the problem is… It looks like Mycroft listens, but cannot speak while squeezelite is running.

I have also tested in with the Plasma-Bigscreen image on a Raspi4 - no success either.

Ideally I would like squeezelite to mute, when Mycroft gets activated, but being able to tell mycroft to stop the music and then interact with Mycroft and let it start the music afterwards again would already be a great state to achieve!

I am thankful for any help to solve this! And thanks a lot for all the great work you are doing around Mycroft. It is well appreciated!

1 Like

Nice to see that I am not the only fanboy of squeezelite. I did a post in a multiroom thread here, a while ago. But I was still alone with my fav. multiroom-speaker choice.

Did you take a look at snapcast?

Otherwise you should take a look at MycroftOS - A bare minimal (production type of) OS based on Buildroot

For the next version of MycroftOS I have planned to have proper pulseaudio volume/mute control.

Then it does exactly what you want. As soon as you ask something while squeezeliye is playing it is muting and ducking the volume while it listens and speaks. No controlling squeezelite by voice as of yet, that is on the list. (Squeezelite is already included)

1 Like

Wow. Missing words. Do you have an ETA for this next Version? Will follow the thread.

@Alcapond

That’s exactly what I have in mind right now. Has there been any progress?

It would be a waste to have my Pi’s just playing my music when they can also act as Mycroft devices.

1 Like

I am using the beta 0.7 version or so for months now. Unfortunately it doesn’t allow to update mycroft, so I am eagerly waiting for the final release. But I can confirm, this working perfectly. Have this also integrated into Home Assistant, running multiple modipys for a full featured multi-user home, with individuals musik streams, that follow the individual users etc. Very happy with it and MycroftOS /OVOS makes my life on the rasperry really easy.

1 Like

Blessings everyone, Just started with LMS as a way to control my music on my server through my phone instead of having to have the plex app open on another device with speakers connected to it.

current setup is
headless server with media
-ubuntu server 20.04
-openhab3
-plex
-squeezebox w/ squeezelite (To play music from the server speakers)
-zoneminder

Raspberry pi4 2GB with touchscreen.
-ubuntu server 20.04
-mycroft-core & gui (Haven’t gotten touch to work yet)
(installed using these instructions mycroft-gui-mark-2_20.04_standalone – TTD-Public )

I would really like this. Tried to install squeezelite on mycroft but had problems.
How did you get squeezebox on openhab? I see that it is a binding, but when going through the interface, it doesn’t show up.

Did this and the same thing happened to me. (Minus the stacked messages coming through all at once.)
Thought it would be cool to have mycroft play music from the server.

I seen on another thread that you have already implemented this. How could I copy this? I hope that it is not too complicated. I can ssh and use the common linux commands but not the building/compiling/writing scripts.

Blessings and I hope to hear a reply soon.

If you are looking for “muting/ducking while listening”, yes this can be done utilizing PulseAudio. Below information is already here and there on the forums, but let’s all put in in one post for future references.

Sent all sound to PulseAudio
First we make sure we use PA for all sound input and output, by forcing ALSA Userland to forward everything to PulseAudio. For this you need to have the “alsa-plugins” package available / installed.

Replace the content of “/etc/asound.conf” with the below content;

# Use PulseAudio by default
pcm.!default {
  type pulse
  fallback "sysdefault"
  hint {
    show on
    description "Default ALSA Output (currently PulseAudio Sound Server)"
  }
}

ctl.!default {
  type pulse
  fallback "sysdefault"
}

Configuring PulseAudio
Now we need to (re)configure the PA settings. Below are the settings we currently use for OpenVoiceOS (OVOS).

Open your PulseAudio daemon.conf file and implement the below settings;

# OpenVoiceOS Audio Settings
resample-method = ffmpeg
default-sample-format = s16le
default-sample-rate = 44100
alternate-sample-rate = 48000
avoid-resampling = true
flat-volumes = no

I will explain the above settings a bit, so you can decide if you want them or not, or need to alter them a bit for your system / hardware. Following a bit different order for explaination sake.

avoid-resampling = true : If possible avoid resampling. This means that if the hardware and/or driver supports the below settings, configure the device to use them instead of resampling the stream. This does not mean that resampling will never happen. If the hardware can not be set / configured it still resamples.

default-sample-format = s16le : This sets the default sample format to “bits, signed, little endian” which is a ‘safe’ setting for most hardware.

default-sample-rate = 44100 : This sets the default sample rate to 44.1 kHz which again is a common, widely used ‘safe’ standard.

alternate-sample-rate = 48000 : If 44.1 kHz is not possible, use 48.0 kHz as alternative next commonly used ‘safe’ standard.

resample-method = ffmpeg : This sets to use ‘ffmpg’ as the resample audio library. For the Raspberry Pi with limited resources this is in my opinion the best compromise between speed, resources and quality. Just MAKE SURE you have the ffmpeg package installed on your system.

flat-volumes = no : As the standard mycroft volume skill is controlling the sound using the ALSA Master control (which will work because we push everything to PA anyhow), don’t let PulseAudio individually control the volumes of the different applications. This prevents that the PA makes a mess of the different volumes.

Next we need to configure the modules used by PulseAudio. If you run PA as systemwide deamon alter the ‘system.pa’ file. If you run as a normal user, alter 'default.pa’file. Make sure the settings reflect the below settings;

### OpenVoiceOS Audio Settings
unload-module module-suspend-on-idle
load-module module-role-ducking
load-module module-combine-sink sink_name=OpenVoiceOS
set-default-sink OpenVoiceOS

Again a quick run through.

unload-module module-suspend-on-idle : Make sure we do not suspend the the audio device when being idle for some time. You can also uncoment the loading of it elsewhere, I choose this method so I can just compy & paste that block at the bottom of the file.

load-module module-role-ducking : This module is used by Mycroft to lower the volume of the sound output as soon as it hears the wakeword.

load-module module-combine-sink sink_name=OpenVoiceOS : This takes all sound outputs / sinks and combines them all into a new virtual sink called ‘OpenVoiceOS’ (Call it whatever you want). With this enabled it doesn’t matter where you connected your speaker, be it HDMI-1, -2 3.5 jack or whatever. If will receive the sound.

set-default-sink OpenVoiceOS : Make the above configured sink the default of PA.

Now for the last configuration change we need to scroll up in the file and find the loading part of sound devices based on udev and add the ‘tsched=0’ variable to the loading of the module. Below the code block as being used within OpenVoiceOS;

### Automatically load driver modules depending on the hardware available
.ifexists module-udev-detect.so
load-module module-udev-detect tsched=0
.else
### Use the static hardware detection module (for systems that lack udev/hal support)
load-module module-detect
.endif

As the Raspberry Pi does not have a Real Time Clock (RTC) / hardware clock, we are better of to NOT use time based scheduling of the soundstream. This will decrease the delay of sound output a lot, with the trade off that some heavy / high bitrate streams might have some glitches at the start. For most sound output and the voice output this is not a problem most of the time.

Configuring Mycroft
With above settings PA is in shape to tell Mycroft to make use of the mute while speaking. This can be done by adding the "pulse_duck": true to your mycroft.conf TTS section. As example, below the specific block of code again used within OpenVoiceOS;

"tts": {
    "module": "mimic2",
    "mimic2": {
      "lang": "en-us",
      "url": "https://mimic-api.mycroft.ai/synthesize?text=",
      "preloaded_cache": "/home/mycroft/.cache/mycroft/preloaded_cache/Mimic2"
    },
    "pulse_duck": true
  },

Just make sure you properly format as json / minding all the comma’s and brackets here and there.

Now reboot and see if everything works as expected. Enjoy…