Play a local mp3 file on Alexa Echo dot

Working scripts examples. Put in your S3, your skill, your echoname, and your mp3 file.

alexa_play_mp3:
  sequence:
    - service: input_text.set_value
      data_template:
        entity_id: input_text.alexa_actionable_notification
        value: >
          {"text": "<audio src='https://yourfile.s3.amazonaws.com/{{mp3}}'/>", "event": "none"}
    - service: media_player.play_media
      data_template:
        entity_id: >
          {% if alexa_device %}
            {{ alexa_device }}
          {% else %}
            media_player.yourechodot
          {% endif %}
        media_content_type: skill
        media_content_id: amzn1.ask.skill.e4280a53-blahblahblah

alexa_knocking:
  sequence:
    - service: script.alexa_play_mp3
      data_template:
        mp3: knocking.mp3

alexa_think:
  sequence:
    - service: script.alexa_play_mp3
      data_template:
        mp3: think.mp3
1 Like

I get “There was a problem with the requested skills response”… :frowning: I edited the script names, but using your example script names, I should be able to just call the “alexa_knocking” or “alexa_think” scripts right from Services with no Service Data correct?

activate_alexa_actionable_notification:
  description: 'Activates an actionable notification on a specific echo device'
  fields:
    text:
      description: 'The text you would like alexa to speak.'
      example: 'What would you like the thermostat set to?'
    event_id:
      description: 'Correlation ID for event responses'
      example: 'ask_for_temperature'
    alexa_device: 
      description: 'Alexa device you want to trigger'
      example: 'media_player.bedroom_echo'
  sequence:
    - service: input_text.set_value
      data:
        entity_id: input_text.alexa_actionable_notification
        value: '{"text": "{{ text }}", "event": "{{ event_id }}"}'
    - service: media_player.play_media
      data:
        entity_id: "{{ alexa_device }}"
        media_content_type: skill
        media_content_id: amzn1.ask.skill...........


alexa_play_mp3:
  sequence:
    - service: input_text.set_value
      data_template:
        entity_id: input_text.alexa_actionable_notification
        value: >
          {"text": "<audio src='<audio src='https://dbs179.s3.amazonaws.com/audio/{{mp3}}'/>", "event": "none"}
    - service: media_player.play_media
      data_template:
        entity_id: >
          {% if alexa_device %}
            {{ alexa_device }}
          {% else %}
            media_player.office_echo
          {% endif %}
        media_content_type: skill
        media_content_id: amzn1.ask.skill..........


alexa_play_barking:
  sequence:
    - service: script.alexa_play_mp3
      data_template:
        mp3: labrador-barking.mp3


alexa_play_siren:
  sequence:
    - service: script.alexa_play_mp3
      data_template:
        mp3: siren_noise.mp3
1 Like

Your Alexa_play_mp3 points to your S3 site. If I understand your previous messages, the only file you have at that site is the dog barking file. I did not send you my actual S3 site url, so it is not possible for you to play knocking.mp3 or think.mp3.

If you are saying you have a script (x) that sets the mp3 parameter value and runs script.alexa_play_mp3, then yes. You should be able to run script X from Services without service data.

Sorry, my last post wasn’t very clear, but you got the gist of it I think.

I have two mp3s on my S3 now for testing, labrador-barking.mp3 called from the alexa_play_barking script and siren_noise.mp3 called from the alexa_play_siren script. Everything in my scripts has been edited from your examples to point to my S3 storage, my Alexa Skill ID, my skill names, and my mp3 files.

If i try to run either of the alexa_play_barking or alexa_play_siren scripts from services with no service data Alexa says “There was a problem with the requested skills response.”, but I get no errors in Home Assistant.

Any ideas?

Test that you can play the mp3(s) via a browser (url to s3 file). If so, you have an error in the skill you created or in the media_content_id of the skill.

Another test is to call the alexa play mp3 script via services supplying service data for mp3 and echo device.

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:

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.