Playing MP3 on raspberry pi

I guess i exhausted my research in here in finding a 100% local solution in playing MP3 file in my house. I tried TTS, but locally TTS sounds like the robot in space invaders. So I gave up the tts idea. Since I don’t have that many messages I want to use (may be 5 or 6) I thought to create the mp3 and store them on a raspberry pi.

The HU and the raspberry pi are on the same local network which is a different network than my normal wifi. This is to make sure they are never on internet. They talk just fine.

I do not use Sono or GH. I really really want to stick with the pi. I’m sure somewhere there are drivers for that. But where? I searched and searched.

Anyone can lead me to the right direction?

Thanks

I've not tried this, but the first thing that comes to mind for me is Node Red? Think something like that could be done in Node Red?

2 Likes

Sure. But it is probably easier setting up a small webserver on the Pi (even using something like a Python or Ruby one-liner), and then using http commands out of RM to run scripts that play the specified mp3.

1 Like

I have been told that node red requires internet. And I think it does. Not so sure about that.

That sounds very interesting. I’m not yet familiar with all that stuff. I have HU for a month or so, and the pi for about a week. I’ll have to dig into it if I can’t find a ready option.

Thanks

Nope. Just needs to be able to access your Hubitat Elevation (i.e. LAN access is necessary, internet is not).

1 Like

I wrote some code to do TTS from HE to MQTT to Ubuntu and OSX. It's uses the same voices as all HE TTS devices which means it requires internet (Amazon) to create the mp3. There's a groovy driver for HE and python code for Linux, OSX to pull the mp3 from HE and play it. Sound quality depends on your sound system (pi's are not good). It has no ability to detect or control who or what might be using the speakers. For Pulseaudio systems like Ubuntu the sounds mix. Same for OSX. I haven't tried the pi (which doesn't use PA by default).

TTS without the cloud is possible if you want dig deep enough and spend enough time and money.

If you configure you Pi as a webserver then I have an app that I have been using for almost 4 yrs to do this without problems
First on ST then ported to HE

I use it with mp3’s for some of my repetitive announcements

Andy

2 Likes

@Guytas

Andy's suggestion is the simplest solution for using your own mp3s for TTS. And really setting up a webserver on a Pi to serve up the mp3 files is simple.

2 Likes

This is exactly what I need to do. And I also need to make the webserver active to stores the mp3.
I can manage setting it up no problem. I’m very interested thanks.

Ps: does NGINX would do the job as webserver?

1 Like

I’m sure ngix would work fine.
All you need is for the webserver to present the mp3 to the app when queried.
Any webserver will do that for you

1 Like

The app I use is ‘mp3 event player’
It’s on my website under ‘apps -> unsupported apps’
I will actually support it, it’s just so old I haven’t developed anything on it for ages

Https://cobra-apps.co.uk

Andy

2 Likes

Ok, super. Thanks. I’ll go get it in a little while...

Ok, got the webserver running, installed your app, but then.... I’m lost :weary:

First, I’m not understanding the concept of parent and child in an app. And then, when I select the mp3 event player, I need to select a “speaker”. In my mind, I thought that the mp3 event player would be the “speaker”. What other speaker I need to use?

I was hoping to get the sound directly out of the raspberry pi either on the earphone plug or using the Bluetooth option. What am I missing?

I use VLCthing Again with VLC Thing and Hubitat to play TTS out of the raspberry’s audio jack.

2 Likes

Yes I read about that. But my VCL does not have the menu I saw in screen snapshots. I was kind of lost there.
The idea was great, but when I saw that the menus were so different, I assumed that they were not talking of a vcl on a raspberry pi.

Here is the rulemachine rule to let my wife know when the mail arrives in Spanish.

I’ve also set up my Daughter’s raspberry to play a chime audio file when a door opens in her house.

Ok, but I still don’t understand what VLC we are talking about. Are we talking about the VLC that comes built in to the raspberry pi? Caus I can’t find when to set up the http in that VLC.

Yes, the VLC that comes built in with the raspian os. Let me know and if I have time I can help you set it up. It may me a little painful.

Just set up Apache2 on the Pi. It is so simple a child can do it (I managed it, so that proves it :crazy_face: It's literally one line typed into the terminal window and BOOM! There it is.

sudo apt install apache2 -y

(of course do your normal updates etc prior).

Here's the official info, direct from the horse's mouth...

https://www.raspberrypi.org/documentation/remote-access/web-server/apache.md

Once done, type in http://[your_Pi_ip] and BOOM! (again sorry, its the weekend) there is the Apache page.

Then navigate in the terminal window to where this is as follows...

cd /var/www/html

Create a directory to put your mp3 files/sounds in.

sudo mkdir sounds

Set the privileges you want to enable copying your files there... Something like

sudo chmod 666 sounds

Add your sounds (I use Teamviewer which is absolutely awesome and yet absolutely free and includes the file transfer functionality, with drag & drop) and reference them in your Rule Machine rules as....

http://[your_Pi_ip]/sounds/zombie_eating_brains.mp3

(as an example, which I use as one of my door bell sounds ha ha ha).

It's completely reliable and very fast.
Enjoy!

If I'm understanding correctly, I think you're talking about playing the mp3 through some kind of network speaker that Hubitat can play to? I think the OP's issue is that he wants the Pi to play the mp3 out of its own speaker.