I need TTS that generates mp3 file and plays it on remote Linux machine

I have spent several hours today trying to figure out how to play notifications from automations on remote Linux machine with speaker. There are many solutions out there, but none of it woks for me so far or it seems too complicated to setup.
I have Voice Assist working fine on that remote host using Wyoming Satellite, but it currently does not expose media player to send custom TTS messages on it.

So I am thinking to go different way about it, which to use ssh to play those notifications.
I have the last step sorted, which is how to play the notification:

ssh user@remote_speaker1 "play notification.mp3"

Now the harder part is to find some simple way to generate those mp3 files in TTS.
I see 2 ways how to possibly do this:

  1. Use HA to generate mp3 from TTS and copy over ssh/ftp/smb
  2. Send a text string to remote host and generate mp3 in place.

I am not sure which one is better, I would say 1. should be simpler to achieve, but right now I don’t know how to go about either of those.
I found Chime TTS integration which should be able to do it, but it expects the media player target which I don’t have.

I could actually use some permanent notification files that do not need any refresh in style of “humidity is high in the living room” and just use the ssh command to play them, but I want to read values from sensors too so the notification should be more like “humidity is $number in the living room”

Or perhaps there is a simple way to create a media player that plays remotely on remote Linux host but I have not found out how to create it yet.

You can use Chime TTS and Music Assistant to send TTS announcements to Wyoming satellites if you have snapcast and pulseaudio installed on them also.Chime TTS will also generate a mp3 file and a url if needed.
Easiest way would be to install snapcast and Pulseaudio on the satellite. It works perfectly.

1 Like

I have seen that solution too, but I thought it sounds bit difficult to setup, too many components involved. On the top of it I use Pipewire instead of Pulseaudio on the remote speaker system so it might be extra hassle to configure.

I might still give it a go as I would like to have music option in the future too.

It this a good guide to follow? wyoming-enhancements/snapcast/docs at master · FutureProofHomes/wyoming-enhancements · GitHub

All I have installed on my Satellites is Snapcast and Pulse Audio.
That guide you linked to is the one I followed.

Got it thank you, I followed the guide and it works now! I just received the first voice notification from HA automation.
Very happy! Thank you.

As expected, Pipewire prolonged the installation process quite a bit and things are still bit messy atm.
The problem I am still facing is that the guide directs to install the snapclient service in system space while pipewire-pulse.service is running in user space and i believe for that reason it fails to start.

$ sudo systemctl start snapclient.service
$ sudo journalctl -u snapclient.service -f
snapclient[4932]: Home directory not accessible: Permission denied
snapclient[4932]: Exception: Failed to connect to PulseAudio context, error: Connection refused
snapclient[4932]: Snapclient terminated.
systemd[1]: snapclient.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: snapclient.service: Failed with result 'exit-code'.
snapclient.service: Scheduled restart job, restart counter is at 5.
systemd[1]: Stopped snapclient.service - Snapcast client.
snapclient.service: Start request repeated too quickly.
snapclient.service: Failed with result 'exit-code'.
systemd[1]: Failed to start snapclient.service - Snapcast client.

Resolved by running the snapclient as user:

$ snapclient -h 192.168.0.21 --player pulse:property=media.role=music --sampleformat 44100:16:*
2024-05-22 04-48-50.703 [Info] (Snapclient) Version 0.28.0, revision 000ea4f3
2024-05-22 04-48-50.703 [Info] (Connection) Resolving host IP for: 192.168.0.21
2024-05-22 04-48-50.703 [Info] (Connection) Connecting to 192.168.0.21:1704
2024-05-22 04-48-50.704 [Notice] (Connection) Connected to 192.168.0.21

So the remaining task is to move the client service from system to user space.
I am not very comfortable with systemd, but at least I will learn something new by doing that and perhaps I can write it up as a new guide for other people that will have the same scenario as all Linux distributions are moving away from Pulseaudio to Pipewire service by default.

One other problem is that the snapclient crashes a lot:

2024-05-22 14-21-24.034 [Info] (Stream) outputBufferDacTime > bufferMs: 139762396678 > 1000
2024-05-22 14-21-24.034 [Debug] (Stream) Failed to get chunk, returning silence
2024-05-22 14-21-24.054 [Info] (Stream) No chunks available
2024-05-22 14-21-24.885 [Error] (Connection) Error reading message header of length 0: End of file
2024-05-22 14-21-24.885 [Debug] (Connection) Disconnecting
2024-05-22 14-21-24.885 [Debug] (Connection) Disconnected
2024-05-22 14-21-24.885 [Debug] (PulsePlayer) Destructor
2024-05-22 14-21-24.885 [Info] (PulsePlayer) Stop
2024-05-22 14-21-24.885 [Info] (PulsePlayer) Disconnecting from pulse
2024-05-22 14-21-24.885 [Debug] (PulsePlayer) State changed 6: terminated
2024-05-22 14-21-25.885 [Info] (Connection) Resolving host IP for: 192.168.0.21
2024-05-22 14-21-25.885 [Debug] (Connection) Resolved IP: 192.168.0.21
2024-05-22 14-21-25.885 [Info] (Connection) Connecting to 192.168.0.21:1704
2024-05-22 14-21-25.886 [Error] (Connection) Failed to connect to host '192.168.0.21', error: Connection refused
2024-05-22 14-21-25.886 [Error] (Controller) Error: Connection refused
2024-05-22 14-21-25.886 [Debug] (Connection) Disconnecting
2024-05-22 14-21-25.886 [Error] (Connection) Error in socket shutdown: Transport endpoint is not connected
2024-05-22 14-21-25.886 [Debug] (Connection) Disconnected
...
2024-05-22 14-21-31.892 [Info] (Connection) Resolving host IP for: 192.168.0.21
2024-05-22 14-21-31.892 [Debug] (Connection) Resolved IP: 192.168.0.21
2024-05-22 14-21-31.892 [Info] (Connection) Connecting to 192.168.0.21:1704
2024-05-22 14-21-31.893 [Notice] (Connection) Connected to 192.168.0.21
2024-05-22 14-21-31.893 [Info] (Connection) My MAC: "00:24:1d:cc:54:9a", socket: 8
Segmentation fault

Should be easy to resolve by some watchdog script that will rerun the client service, either on the Satellite itself or HA.