Resume playing Spotify after playing local mp3 file or TTS announcement on same RPi3

I’ve searched the forum for a solution, but only found pieces of information here and there, and eventually couldn’t put all the pieces together. So I’m now asking this in a new thread:

When I’m playing Spotify and I need to output TTS or local mp3-file, Spotify is no longer able to resume playing because of the ‘Device or resource busy’ error I’m getting. How to properly ‘unreserve’ media player after TTS or mpd has finished playing local mp3-file?

Spotify Connect log after Spotify has been paused, TTS announcement is finished, and trying to resume Spotify:

11:17:55 [ERROR] e(BAlsa error PCM open ALSA function 'snd_pcm_open' failed with error 'EBUSY: Device or resource busy'
11:17:55 [ERROR] e(BCould not start audio: Alsa error: PCM open failed
11:18:00 [ERROR] e(BAlsa error PCM open ALSA function 'snd_pcm_open' failed with error 'EBUSY: Device or resource busy'
11:18:00 [ERROR] e(BCould not start audio: Alsa error: PCM open failed
11:18:05 [ERROR] e(BAlsa error PCM open ALSA function 'snd_pcm_open' failed with error 'EBUSY: Device or resource busy'
11:18:05 [ERROR] e(BCould not start audio: Alsa error: PCM open failed

This is my configuration:

media_player:
  - platform: spotify
    client_id: !secret spotify_client_id
    client_secret: !secret spotify_client_secret
  - platform: mpd
    host: !secret mpd_ip

tts:
  - platform: google_translate
    service_name: google_say

Installed add-ons are ‘Mopidy’ and ‘Spotify Connect’

I would be fine with a solution where everything is just mixed together, but ultimately it would be very nice to pause Spotify when there’s a TTS coming through.

2 Likes

Did you ever get anywhere with this?

Never with just the one RPi with Hassio. I managed to get it working by implementing a second RPi and using that as a media player. It can handle both Spotify and TTS and mix those audio streams nicely together.
This second RPi has Hifiberry DAC on it. Setting up that Hifiberry so that it can mix two sources was a major pain in the a**, and it took me several weeks, but now it’s working flawlessly. If you ever need help with that I’m glad to help.

Hello,

I am using a custom addon (search for “local_audio_player”) to play mp3 files through a raspberry pi. When I have spotify connect playing, it doesn’t stop, both things play at the same time.
I think that my next project is to set volume down to spotify when mp3 is played and set volume up when finished.