Playing MP3 on raspberry pi

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.

Lol. I think I confused everybody here. My English and my knowledge in the HE and pi are not so high and this might be part of the reason.

But I understand that we have 3 things going in this thread:

  1. TTS. I had gave up using local TTS because the sound was too robotic for my taste. But then, @JBrown brought back the idea of the tts with the VLC thing. I had read about it and thought I didn’t have the right VLC for this. But now i know that it seems that I had the right one. Just don’t know where to set the HTML. But the tts is not my first choice any more. I really have some dought on the quality of the voice we can get locally.

  2. @Cobra offers an app to play mp3 but required me to set up webserver. So I query on webserver. And I already installed a webserver and it is up and running. Perfect.

  3. Then the app from Cobra I don’t understand how it should be working. This is the point I am at right now. The speaker list is empty

To clarify my needs.... I just want to have a speaker :speaker: (literally just a speaker) connected on the pi’s audio port to play a mp3 like “the door is open” whenever someone opens the door. And all this totally local (without internet). The HE is already talking to the pi for influxdb and Grafana.

That part I can do. But where do you enter the

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

In HE?

Yes, in a rule to trigger the playback of your file to a device. For example, a Nest Mini. Set up a rule and use Custom Action to tell it to play the track (your mp3 file located on your Pi). Like this example which uses randomise to play different dog and zombie sounds when the front door motion detector gets triggered) ... :crazy_face:

Yes, but your Nest Mini is what give you the selection that I don’t have. If I create a virtual device “sono player” then I see the play track option. That also opens up the “speaker” option of @Cobra app.
The way I understand it is that I need a device driver that would represent the pi as a music device or something like that.

Ok ok i think I get it. The vcl thing is the missing puzzle. I’m setting it all up now.... I cross my fingers.

Oh sure, sorry, if you just wanna play sounds on your Pi through your TV. I need to learn to read the whole thread :cry:

ok, I got it partially working. In the VCL things driver, if I use the PlayTrack button, it works fine. But in a Notifier, when I enter the same mp3 file under Music device, I get an error in the Log.

groovy.lang.MissingMethodException: No signature of method: user_driver_statusbits_VLC_Thing_519.playTrack() is applicable for argument types: (java.lang.String, java.lang.Long) values: [Music/arrive.mp3, 50]
Possible solutions: playTrack(java.lang.Object), nextTrack() (playTrack)

I tried to insert several debug trace in the driver, but I cant seem to catch this.

Ok, this VCL thing need some work. It take way too much power on both, the HE and the pi.
I see that I’m not the only one with this kind of problem.
I don’t see why it has to poll the webserver every minute. May be to keep it alive? But still.... too heavy on the traffic. Sometime, it takes several seconds before the keystrokes appears on the pi while this thing is running.

And as for your app @Cobra I don’t quit understand the relation with a webserver. Your app triggers an mp3 to be sent to a music device. Nothing related to a webserver the way I see this. Am I missing something?

The webserver is used to ‘host’ the mp3’s as you cannot store them on the hub.
I apologise, I had assumed that you already had working speakers on your hub and just wanted a way to play mp3’s

2 Likes

Have you considered using Node-RED for this? Your post made me curious, so I did a quick search and found that there are at least a couple of node modules for playing mp3 files. I've yet to try it out, but it looks like it should be very easy.

If you've never tried Node-RED, it might sound complicated at first, or unnecessary for such a simple task, but it's actually extremely to install on a Pi. If you'd like to explore this option, and you're not familiar with Node-RED, I'd be happy to offer more help.

Thanks. I see also @april.brandt mentioned that I should try none red. Funny that in another post, people were saying that you need internet to use node red. May be I’ll try this later.

For now, I am almost done using python and writing the driver in Hubitat. I’m adding config file so other people may adjust it to their needs.

See this from another post:

aaiyarAmbassador

27d

Absolutely not. However, you will need an external permanently-on computer that runs Node-RED. Something like a Raspberry Pi would be adequate.

Ooops. I forgot that April had already suggested it. I'm pretty sure she's right; This should be easy with Node-RED, and I'm pretty sure it doesn't require an Internet connection, unless you want to connect it to cloud-based services.

It's definitely possible. My Google home plays "I am your father" mp3 when I get within our geofence. I found someone else's example online and tweaked it for my use. The mp3 is saved on the RPi.

1 Like

Hehe. Now we’re far from being local: the geofencing, the google home, the iPhone. Lol. This is totally the opposite of me. But... I’ve been there... it is very nice but... it’s no longer my need.

I will come back and check on that node red later. I got my local mp3 now so I’m pleased. I will share this later when it’s cleaned up properly.