Playing MP3 on raspberry pi

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.

Would you mind sharing your final solution? I would also like to use a Pi to play pre-recorded MP3 announcements using HE. Did you end up using the VLC integration to trigger and play the MP3 on the Pi? I see that you mentioned writing a custom driver for your solution. Would you please share it with us? Thanks!

This is how I play a mp3 on a raspberry I use the exec node, I’m sure they’re are other ways of doing it.

2 Likes

This is a great idea! Especially since I just finished setting up Node-Red :slight_smile: Thanks!

I'm assuming that Node-Red is running locally on the Pi? Is that how you're able to run the command with the Exec node?

1 Like

Yes

1 Like

Ok, thanks.