Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio tag to play MP3 file does not work #1412

Closed
stefanstranger opened this issue Nov 13, 2021 · 10 comments
Closed

Audio tag to play MP3 file does not work #1412

stefanstranger opened this issue Nov 13, 2021 · 10 comments

Comments

@stefanstranger
Copy link

stefanstranger commented Nov 13, 2021

Describe the bug
I'm trying to use the Alexa Skills SSML Audio tag reference to have an external hosted mp3 file being played. But the text is being spoken but the audio mp3 file is not being played.

More information about the audio tag can be found here.

To Reproduce
Steps to reproduce the behavior:

  1. Open Development Tools in Home Assistant
  2. Try to execute the following yaml code:
service: notify.alexa_media
data:
  message: >-
    Play doorbell.
    <audio src="https://www.stranger.nl/doorbell-2.mp3"/>
    Did you hear the doorbell ring?
  data:
    type: announce
    method: all
  target:
  - media_player.stefan_s_echo_dot
  1. You should hear the messages spoken, but the mp3 is not being played.

Expected behavior
Besides the message text being spoken the doorbell-2.mp3 should also being played.

Screenshots
If applicable, add screenshots to help explain your problem.

System details

  • Home-assistant (version): 2021.9.7
  • Hassio (Yes/No): Yes
  • alexa_media (version from const.py or HA startup): 3.10.10
  • alexapy (version from pip show alexapy or HA startup): 1.25.1
  • Amazon 2FA is enabled (y/n). Yes

Logs
Please provide logs. We'll be most likely asking for them anyway.

I converted the mp3 file as described by the link from Alexa Skills.

@alandtse
Copy link
Owner

What happens if you try in the app using the ssml? We use the same API call as the app so if it doesn't work there, we can't help here.

@stefanstranger
Copy link
Author

Hi Alan,

Thanks for your response. Which app do you mean?

@alandtse
Copy link
Owner

Alexa mobile app.

@github-actions
Copy link

The issue has received no activity for 60 days and will be closed in a week.

@Giancky79
Copy link

Giancky79 commented Jan 17, 2022

i reproduce mp3 with type: tts
maybe is not compatible with alexa

@alandtse
Copy link
Owner

Please show your service call that worked so others can replicate it.

@Giancky79
Copy link

action:  
  - variables:
      url: !secret external_url
  - service: media_player.volume_set
    data:
      entity_id: >
        {{states('input_select.alexa_wakeup_speaker')}}
      volume_level: >
        {{ states('input_number.ringtones_level')}}
  - service: notify.alexa_media
    data: 
      target: >
        {{states('input_select.alexa_wakeup_speaker')}}
      data:
        type: tts
      message: >
        <audio src='{{url}}/local/audio/ringtones/{{states('input_select.ringtones')}}.mp3'/>

i like's with template but if you want normal

put

<audio src='https://domain/local/audio/ringtones/audio.mp3'/>

with 443 no need :port, different with 812x

but alexa need a clean mp3, for this problem you have 2 solution

The first with linux

ffmpeg -i <input-file> -ac 2 -codec:a libmp3lame -b:a 48k -ar 16000 -write_xing 0 <output-file>
to sample rate 16000

ffmpeg -i <input-file> -ac 2 -codec:a libmp3lame -b:a 48k -ar 24000 -write_xing 0 <output-file>
to sample rate 24000

but i'm too lazy, and i prefer the 2th solution

https://v3.jovo.tech/audio-converter

@github-actions
Copy link

The issue has received no activity for 60 days and will be closed in a week.

@bkarakashev
Copy link

action:  
  - variables:
      url: !secret external_url
  - service: media_player.volume_set
    data:
      entity_id: >
        {{states('input_select.alexa_wakeup_speaker')}}
      volume_level: >
        {{ states('input_number.ringtones_level')}}
  - service: notify.alexa_media
    data: 
      target: >
        {{states('input_select.alexa_wakeup_speaker')}}
      data:
        type: tts
      message: >
        <audio src='{{url}}/local/audio/ringtones/{{states('input_select.ringtones')}}.mp3'/>

i like's with template but if you want normal

put

<audio src='https://domain/local/audio/ringtones/audio.mp3'/>

with 443 no need :port, different with 812x

but alexa need a clean mp3, for this problem you have 2 solution

The first with linux

ffmpeg -i <input-file> -ac 2 -codec:a libmp3lame -b:a 48k -ar 16000 -write_xing 0 <output-file>
to sample rate 16000
ffmpeg -i <input-file> -ac 2 -codec:a libmp3lame -b:a 48k -ar 24000 -write_xing 0 <output-file>
to sample rate 24000

but i'm too lazy, and i prefer the 2th solution

https://v3.jovo.tech/audio-converter

Thank you so much @Giancky79.
I have been pulling my hair for hours and this was the solution for me.
I had to make sure that the mp3 is in the right format. I just used your "ffmpeg" command and all worked like a charm :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants