Speaker/Soundcard for Raspberry Pi 4, best practice, August 2022

I am really frustrated. I followed the instructions, invested into a dedicated Raspberry Pi 4 and lost the whole Sunday to figure out how to get sound out of Home Assistant.

I asked within this forum how to connect via bluetooth. No answer at all.

Using the standard audio output is a nightmare. Even with .wav, that don’t need to be decrypted, Whole words are swallowed. How do I get it running? Isn’t there a documentation of best practice upon the home page how to deal with sound?

  • bluetooth: silence
  • line-out: nightmare
  • finally USB?

Question 1:

Would I get a better sound out of Raspberry Pi 4 using a usb-speaker?

Question 2:

Does a usb-speaker work with Raspberry Pi 4 at all?

Question 3:

What is best practice to get sound out of HA to a speaker and what type of speaker?

thx

1 Like

My experience with both the native RPi 3.5mm jack, and a USB speaker is that it’s a lot easier to use something external (e.g. an audio/video Chromecast) as an audio sink both for TTS announcements and the separate HASS media player.

In short, I gave up on both jack and USB audio output! :frowning:

I wondered if the Yellow audio output might improve matters, but then again, there’s not much between the RPi4 and Compute Module.

1 Like

I was considering going down that road with audio but my RPI is primarily used for transmitting weather data from my weather station (weewx) and home automation (Home Assistant Supervised). I also use my RPI headless and it is an RPI 4b 8Gig running on a 1TB SSD. So, I was going to go down that same road as it still has I believe alot more capacity to handle more “work” and I do have a huge library of music - and right now I have no sound coming from it at all - BUT…

I understand that even the RPI 4 has a pretty lousy audio support and most people that are seriously trying to get something really decent out of it for audio purposes - have typically used a USB connection to the RPI for not a speaker - but specialized audio add-ons to beef up the hardware to supporting better codecs and the like (getting near the edge of my knowledge here). So, if you are a serious audiophile, I would strongly encourage you to look into “sound card raspberry pi” under google google or duckduckgo. A quick search I found was: https://www.hifiberry.com/

Hope that helps!

Thanks James, at least I see I am not alone. Using Chromecast, obviously a Google device, still requires a connection to it. Is that easy?

We have installed Amazon Echo. It requires an AWS developer account, to connect Home Assistant to it, which in turn requires a credit card. That is a road to far to go for the simple task to get the sound out of HA, where a cable should do.

I’d say the RPi4 have a lot better DAC (cleaner PSU) that the older models, but you’re quite right that there are lots of hardware hats with MUCH better DAC + digital amp + PSU which range up into the audiophile range (personally - still using 2.5mm2 mains cable as speaker wire!).

The harder bit is the software to drive the RPi hardware - ISTR one of the recent release party videos (was it 2022.06?) used squeezebox + Media Assistant but again, not something I’ve tried for general audio / TTS / music.

Other demos used an ESP32 + a £0.10 DAC in mono which didn’t exactly inspire me! :slight_smile:

For TTS and announcement audio, Chromecast (audio, HDMI or Nest Hub) works pretty well.

For music audio, I tend to use the endpoints directly without HASS - e.g. media on a phone, chromecast to a device or multi-room group. HASS can still play/ pause/ change volume as needed.

No messing about with dev accounts needed - “just works”.

Hello Luds,

in our case the sound output is part of the home automation. It simply shall remind ppl to keep the doors closed in the winter time. Just in case they forget it. So, it’s not even intended to become a full-blown jukebox. A medium quality of sound would do. RPI 4 doesn’t even provide that. One of five words of a sentence is just swallowed.

Before burning more money, I would be lucky to know, what would actually give results. Hifi not even required.

thx

2 Likes

How is the setup.

Do you plug the Chromecast into the HDMI of RPI 4 to get the sound out of it? And what kind of hardware follows behind?

It’s all standalone connected via Wi-Fi

Google / Nest used to sell a small unit with USB power in and a 3.5mm audio jack out that also offered optical out from the same port. Now, the (video) Chromecast has USB-C power and HDMI output to connect to a TV or soundbar. There are options for wired Ethernet, but WiFi works well enough. The next step up is a Nest Hub which adds a touchscreen and audio which can be used to directly cast the HASS GUI for custom control panels.

The device broadcasts via Bonjour / autoconf and HASS discovers the devices automatically. The experience on Android is good, and just about works on the iPhone.

I have a few lines of YAML to play a WAV file or text to speech message on a specific Chromecast as needed. There was a little setup to create the HASS directory for short audio files like a WAV doorbell sound - N.B. these are separate from Media Assistant MP3 / FLAC / etc.

  - service: media_player.play_media
    data:
      announce: true
      media_content_type: audio/wav
      media_content_id: media-source://media_source/local/sounds/alert.wav
    target:
      entity_id:
      - media_player.chromecastaudio1234
      - media_player.hub_max
  - service: tts.google_say
    data:
      entity_id:
      - media_player.chromecastaudio1234
      - media_player.hub_max
      message: '  There is somebody at the door!'
      cache: true

Thank you James for the details. I try to understand what kind of data is send, the sound itself or just information about the sound. Even if I don’t want to Install Chromecast it may give some ideas how to deal with it.

1.) Wav

Where is “media-source://media_source/local/sounds/alert.wav” located, on the HA or on the Chromecast? If it is already on the Chromecast, it would explain why there is no difficulty to get the sound out.

2.) TTS

It is similar here. It seems the message of text is send und the transformation happens on the Chromecast.

So far

I come to the conclusion, that the sound capabilities of Raspberry Pi may be insufficient. Is it the transformation if the digital into the analogue signal, that is lacking?

I would like to get so some results:

1.) What is the cause of the difficulties?

2.) Is this issue limited to the Raspberry Pi, so that other hardware should be recommended on the HA homepage?

3.) What is a simple way to bypass it, that can be recommended as a standard?

Maybe an external USB-soundcard would be a way to recommend as best practice. Is there one known to work with HA?

“I’d say the RPi4 have a lot better DAC”

If the DAC is the bottleneck mine is different. It drops one or two words of a sentence, usually the first word and one in the middle of the sound file. The sound files themselves are tested on the desktop and I even tested different formats.

  1. Locally - you need to create the directory on HASS and add media (easy via a terminal or SAMBA). Chromecast devices are (almost) passive output nodes with no storage. The API passes a URL to play/display, in this case from local HASS storage.
    Media Source - Home Assistant

  2. HASS generates a WAV file using whichever TTS engine, (caches locally it if set), then sends the URL to the Chromecast devices.

My meaning was the RPi4 has a DAC with better audio quality than previous RPi.
The operating system device support on HASS is the same.

I have managed to get a RPi4 USB speaker to play media after watching an “official” HASS video. Sadly, after installing the VLC add-on, VLC was unreliable and worked intermittently. Playing media to the browser or ChromeCast audio sink worked fine.

If you get audio and Media Assistant working. be cautious about loading HASS up with large amounts of media (e.g. MP3). A full HASS backup once would not restore due to a size limit and I had to manually uncompress, remove media, and recompress the backup to rebuild a system.

So it basically uses the DAC of the Chromecast to get better results, while .wav files are transferred via wifi? Then the solution is likely to connect a better DAC.

And then for sure you can address devices in different rooms. There Amazon is to blame not to have an open Interface to Echo Dot. I really don’t want to install a double infrastructure of speakers eating twice as much of power. It’s a reason to sell the Echo Dots once there is a working alternative.

I keep my media files on Synology NAS.

Originally I wanted to install HA also on Synology, but it turned out be difficult. The main development of HA is to be fully supervised requiring an own machine. I am that frustrated as it is the second approach to work with HA and it still doesn’t work out of the box, even for the simple task to output sound.

My experience is Chromecast and browser audio works, local RPi4 doesn’t. The issue could be with my config or perhaps that I tried an early release.

Details are below, but in summary mDNS discovery -> send a URL to play -> media plays.

It may be possible for HASS to play files from a NAS, but they need to be available via HTTP as well as SMB/ NFS/ etc as Chromecast devices only understand HTTP URLs.

After a couple of test albums broke a HASS backup, I decided to keep media and home automation very separate. Chromecast devices are useful as they work with HASS TTS and “effect” audio, and also Android general audio and video playback.

TBH, other streaming protocols like squeezebox, and platforms like volumio might work - just not something I’ve tried. They are supposed to be abstracted as audio sink devices. Again, I’d suggest watching the HASS release party video on YouTube from a couple of releases ago - there were two demos of audio streaming control contrasting audiophile curation and low-fi mono.

Yes, why using HA as a media player? Separation of concerns!

But I want to use language as a user interface with home automation. So some basic features are required and TTS would be ideal. Good TTS still requires a backend like Google or Amazon, I guess.

I have managed to get a RPi4 USB speaker to play media after watching an “official” HASS video. Sadly, after installing the VLC add-on, VLC was unreliable and worked intermittently.

Isn’t it frustrating?! You follow an official video, invest money and then it doesn’t work as promised. In the comments of the video almost nobody reports of this kind of issues.

I post another one asking for USB-soundcards and USB-speakers, that reliable work.