Play a local mp3 file on Alexa Echo dot

Hi, to play local MP3 files on Alexa Echo, you need to draw support from Amazon Music. You should log in to Amazon Music Library with your Amazon account, click the ‘Upload’ button to drag and drop your local MP3 file or select the MP3 file for syncing. Once the local MP3 file is saved to your Amazon Cloud Library, you can directly say ‘Alexa, play Amazon Music’ to play your local MP3 on Alexa Echo. By the way, please make sure you have defined Amazon Music as the default streaming music.

Im having issues using the nabu.casa url as provided in this, Alexa says she is unable to access the uri.
Can you provide a guide on authenticating with the nabu casa cloud service within the alexa skill?

Excellent. Followed this guide and got my custom mp3 audio working. If anyone is using audacity to convert, this is my export settings.

Hey!
I have the skill working and I have the issue that @dougbaptista previously had. I have had no luck getting any Mp3s to play. I can play text though.

Using :

speech = "Hello this is a test <audio src='https://abcdefghij.ui.nabu.casa/mp3/test.mp3' />"

My echo will say “Hello this is a test” followed by “there was a problem with this skills requested response”

I can also play the Amazon Soundbank audio fine. Just not my nabu casa mp3.

I tried a few different Mp3s and also converting them as per the Amazon guides. My file is accessible via URL and plays. Any ideas what else I can try? I am using @florian.ec 's guide.

Did you manage to resolve this?

For all that struggle with url or mp3 problems i found a simple website to test own mp3 files Audio File Converter for Alexa Skills | Jovo

For example, i uploaded ful_system_alerts_melodic_02.mp3 and this audio tag should work for 24h:
"<audio src='https://www.jovo.tech/audio/PpUoD5Ug-ful-system-alerts-melodic-02.mp3'/>" you can also download the mp3. So you can confirm that everything else including the mp3 is ok.

Something else new (for me), i was just able to use the audio tag with notify.alexa_media. Documentation still says “with the exception of the audio tag” The Service call below plays the mp3 on my Alexa Device without any skill involved.

service: notify.alexa_media
data:
  message: "<audio src='https://www.jovo.tech/audio/PpUoD5Ug-ful-system-alerts-melodic-02.mp3'/>"
  data:
    type: tts
  target: media_player.alexadevice
5 Likes

@florian.ec what an awesome resource. Thank you for sharing.
I spent at least 5 hours doing this.

Cheers :smiley:

1 Like

This right here is very underrated news. Thanks @florian.ec!!

The ability to do this without a custom skill changes everything! Just set it up to call a local mp3 file through nabu casa and it worked perfectly!

I did not. It works, sort of, plays the one mp3 flawlessly, then keeps on playing the same mp3 regardless of which I try to call. If I reboot HA, or even wait long enough, sometimes between 5 to 10 minutes the same behavior happens again. I can play either mp3 as expected, but it keeps on playing that mp3.

To be fair, I have messed with it in a while though. I gave up and moved on for a bit.

I have my HASS instance published through Caddy reverse proxy. Everything works fine but it does not like my mp3 when using my server URL. If I use the jovo link it does work. My caddy has a Lets encrypt cert on the site. Anyone run into a similar issue using a reverse proxy?

@florian.ec thanks for the tips and help with this. I got Alexa Actionable Notifications working with Movie quotes!

I created a video on my YouTube channel showing how to use the audio source and the awesome Jovo tool. I will be creating an in depth tutorial on Alexa Actionable Notifications soon.

7 Likes

I seem to be experiencing the same issue with my DuckDNS url, Is there something unique about a Nabu Casa setup that needs to be replicated for other connection types?

1 Like

@MarkWattTech found your video before stumbling on this thread. Great tutorial, thank you for making it.

The only drawback so far is playback of the mp3’s when using a speaker group in Alexa as the target (e.g. media_player.everywhere) doesn’t work. I think part of the problem is you have to set the “type” to “announce” when using a speaker group as a target, instead of “tts”. It appears the audio tag isn’t supported when using “announce”.

Note that I’ve converted my mp3 files using the Jovo converter, and can play them from a browser using my Nabu Casa base url (e.g. https://**MY NABU CASA UNIQUE ID**.ui.nabu.casa/local/mp3/Alexa-tng-red-alert.mp3 ). They all work fine when playing to a single Echo device.

For example, this works fine:

service: notify.alexa_media_everywhere
data:
  message: "Alert, unauthorized access detected."
  title: Intruder Alert
  data:
    type: announce

This, however, doesn’t. It only plays the bong sound that Alexa plays when you use the announce type:

service: notify.alexa_media_everywhere
data:
  message: "<audio src='https://**MY NABU CASA UNIQUE ID**.ui.nabu.casa/local/mp3/Alexa-tng-red-alert.mp3' />"
  title: Intruder Alert
  data:
    type: announce

If you change “type” to “tts”, nothing plays for either.

EDIT:
Figured out a workaround thanks to actually reading the description of the parameter values in the developer tools. This workaround is probably common knowledge or at least obvious to many, but since I was being dense this morning, I figured it may not be readily apparent to others.

If you need to play the mp3 to multiple Echo devices, you have to manually specify each device as a target, such as this:

service: notify.alexa_media
data:
  message: "<audio src='https://**MY NABU CASA UNIQUE ID**.ui.nabu.casa/local/mp3/Alexa-tng-chime-clean.mp3' />"
  target: 
    - media_player.office_echo
    - media_player.living_room_echo_show
  data:
    type: tts
3 Likes

I think you need use Nabu for this to work.

Yes, that is correct.

Since I have a trusted SSL certificate set up in HA (e.g. not a self signed certificate) and port forwarding enabled on my router, I tried using the direct public URL to my HA instance. That decidedly did not work, as expected.

Edit: probably also worth noting that the Jovo Tech site only hosts your converted mp3 for 24 hours, so you pretty much have to have Nabu if you don’t want to create custom Alexa skills.

Thanks. Jovo url is working. What’s special in Jovo url (vs duckdns url)?

Is there a guide for that?

I couldn’t answer that, to be honest. Although, it may not have worked with my direct URL since there is a port included in the address, e.g https://my.custom_ha_url.com:8123. It may be just that Alexa can’t handle the port which probably makes sense. The way my network is set up, https traffic on port 443 is directed to another set of servers behind a proxy that HA isn’t configured as a part of (mainly due to lack of time and necessity). I wouldn’t generally recommend exposing HA to the internet directly, but I had a lot of inconsistent issues with location tracking with HA mobile apps when they were pointed to the Nabu link.

As far as custom skills, I think there is some info closer to the top of this thread, but I didn’t spend any time looking in to it. I’m comfortable creating an Alexa skill, but since using the Nabu url is working for me now, I haven’t had reason to mess with it.

And why would a custom Alexa skill be needed?
If Alexa can play the MP3 from the jovo URL without any skill installed why can’t it play the same MP3 from my own site?
I have a domain with SSL, i dropped the MP3 on there, i can play the MP3 with my browser.
But when i change the URL from:
message: "<audio src='https://www.jovo.tech/audio/lpQALZpJ-de-droger-is-klaar.mp3'/>"
to:
message: "<audio src='https://automatiseer.eu/audio/De-droger-is-klaar.mp3'/>"
Alexa starts complaining about a “Simon Says” skill.

Again, both URL’s are reachable, both URL’s have a valid SSL certificate.
So, what am i missing?

EDIT: Hmmm… i think this explains what is going wrong…

To implement account linking for smart home skills, you must have the following prerequisites:

  • Your system must support OAuth 2.0 and the authorization code grant type.

If you do not have your own authorization server, you can use Login with Amazon (LWA) or any OAuth 2.0 provider that has a certificate signed by an Amazon-approved certificate authority. Note that you cannot use https://letsencrypt.org/, even though it is on the certificate list.

And i’m using Letsencrypt on my domain.

EDIT2:
I moved my SSL from Letsencrypt to Cloudflare, and poof it works, i can play any MP3 without a problem.

EDIT3: and after trial and error i also got it working using Node Red.
afbeelding
And this is the Data field in json

{
    "message": "<audio src='https://automatiseer.eu/audio/kleine-wasjes-grote-wasjes.mp3'/>",
    "data": {
        "type": "tts"
    }
}
3 Likes

Curious if anyone here can help with the converting of the audio files to the amazon required format. I’m trying to use the command provided by the jovo site to do the conversion which is as follows.

ffmpeg -i -ac 2 -codec:a libmp3lame -b:a 48k -ar 24000 <output-file.mp3>

However, it does not seem to be working. If I run a file through the jovo site and then look at it with the file command I get the following.

file iYEHPdGL-fire-dispatch-07-03-2021-09-24-56.mp3
iYEHPdGL-fire-dispatch-07-03-2021-09-24-56.mp3: Audio file with ID3 version 2.4.0, contains:MPEG ADTS, layer III, v2, 48 kbps, 24 kHz, JntStereo

This file will play on the echo using the skill.

However, when I try to convert the same file on my own using the command provided by the jovo site, I get the following output using the file command.

file new_sdr.mp3
new_sdr.mp3: Audio file with ID3 version 2.4.0, contains:MPEG ADTS, layer III, v2, 64 kbps, 24 kHz, Stereo

This file will not play on the echo using the skill. Looking through the documentation I don’t understand why the output of the ffmpeg command is 64kpbs since it should be 48kbps. Any ideas on what I’m doing wrong?

Well that’s annoying! Been trying to get this work with my domain (running letsencrypt) and even tried another one that I found was using cloudflare, and neither worked. Swapped my mp3 code for yours and it worked right away. Wonder what the work around is besides switching certificates…Guess I’ll just have to hose some files 3rd party until I figure something out.