How to send local mp3 file to media player?

Hi there!
Would like to know whitch devices I can use for tts. Google tts is just fine, as I know, so, how should I search the device? Do I need google home, or other speakers are just fine?

I just do not know how to choose. As I understand, it should have wi fi?

And I do not really understand how it works. Home assistant sends text, google tts get it and send info to speaker? Where is text processed? Google’s server? Or on pi (or whatever you are on)? Or on speaker? And can pi send tts by bluetooth, or only via wi-fi router?

———————————

Upd:
Now I am stuck with one question. How to send local mp3 file to media player?

I have JBL Playlist 150 and it goes to sleep after around 15 minutes of rest. If then I send a message to it, it will eat first word (does not pronounce). So I need to send some “ding” sound to it first. Or is there another way to wake it up? Service media_player.turn_on does not do anything. Setting up volume does not help either

The google TTS engine just produces an audio file of whatever you requested it say. HA can then tell a media_player device to play that through a HTTP stream made available on the HA webserver. Further detail here

So, the main requirement for media player is that it should be controlled via http? Any suggestions on speaker?

I still can not find speaker which would help me. Should it just connect to wi fi? Are there another requirements?

The requirement is that it’s a media player supported by Home Assistant

Have you tried looking at the list of supported media players?

1 Like

Oh, i was googling speakers which can be controlled via http…
I did not think that there is this nice way to find what I need, thank you
Sorry…

And one last question. Does it matter which language I use for speaker if tts supports it?

JBL Playlist 150 has google cast, so it should be controlled via google cast component?
So it should be possible to send audio file to it using google tts (russian language)
Am I getting everything right?

No - TTS converts your text into an audio file (MP3 by default) and then the speaker plays the audio file. The speaker doesn’t provide the TTS capability - HA does.

Yes, which will give you all the features of any other cast device.

1 Like

Now I have working speaker, just would like to know how to change voices. I see that it is possible


But can not find options and examples

One more - I can not understand should I use cased files or I always use written text in script like this:

'15517202925102':
  alias: Say good morning
  sequence:
  - service: cover.open_cover
    entity_id: cover.curtain_158d0002c54874
  - delay: 0:0:3
  - service: switch.turn_on
    entity_id: switch.wall_switch_right_158d00022363c5
  - service: tts.google_translate_say
    entity_id: media_player.kabin
    data_template:
      message: "Доброе утро. Сейчас {{states('sensor.time')}} утра. В Москве {{states('sensor.outdoor_temperature')|int}} градусов. До работы ехать {{states('sensor.waze_travel_time')}} минут."

One more issue. I have JBL Playlist 150 and it goes to sleep after around 20 minutes of rest. If then I send a message to it, it will eat first word (does not pronounce). If it is not “asleep” it says everything just fine. I tried to use service media_player.turn_on but that did not help - speaker was still asleep after that (I used 5 seconds delay after that). Then I tried to send “.” first, wait, then send main command. That did not work out too. Speaker does not wake up from first “.”
Need help on this. Here is my script for now:

'15517202925102':
  alias: Say good morning
  sequence:
  - service: tts.google_translate_say
    entity_id: media_player.kabin
    data:
      message: "."
  - service: media_player.volume_set
    entity_id: media_player.kabin
    data:
      volume_level: 0.4
  - delay: 0:0:2
  - service: cover.open_cover
    entity_id: cover.curtain_158d0002c54874
  - delay: 0:0:3
  - service: switch.turn_on
    entity_id: switch.wall_switch_right_158d00022363c5
  - service: tts.google_translate_say
    entity_id: media_player.kabin
    data_template:
      message: "Доброе утро. Сейчас {{states('sensor.time')}} утра. В Москве {{states('sensor.outdoor_temperature')|int}} градусов. До работы ехать {{states('sensor.waze_travel_time')}} минут."

That, as it says, depends on the platform. Google’s TTS doesn’t support it for example.

Not sure what you mean by that I’m afraid.

Check to see if you can detect this with the state of the player. Maybe too after you wake it up you need to play something that makes an actual sound, a full stop may not. For example you could use a media_player.media_play command to play an MP3 file that goes “ding”, wait a few seconds, then make your TTS call.

As I see, service media_player.media_play does not have any parameters where I could play a mp3 file.


also I have this in logs

Maybe I should use media_player.play_media?

But this doesn’t work at all right now. Nothing in logs

So, how should I do that “ding”?

I tried to say “good morning” first then wait and send main message. That worked - i heard “rning” and then my message. But how should I make “ding” sound? Is it even possible to play mp3 file from config folder?

Isn’t that common issue? Guys, do you use google home? How does it work in this scenario? Does not it eat first word after sleeping? I have just bought the speaker and can return it and go with another one.

As before, just want to be sure witch model works perfectly (and is not pricy, actually).

Yes, one of mine:

  - service: media_player.play_media
    data:
      entity_id: media_player.cast_second_bedroom_speaker
      media_content_id: https://myhost.dynamic.dom:18443/local/sounds/sub_alert.mp3
      media_content_type: music

Pick an MP3 that has a “ding” sound, or something else, doesn’t really matter what. Heck, try an opening TTS of A.

Thank you for your help.

  1. As I found out speaker wakes up only if I send 5 or more letters. Sending “hi” did not work. It was not pronounced and after delay first word of my main phrase again was eaten. If i use more letters like “heelloo” - I hear “loo” and then my main phrase.

  2. I am doing something wrong with mp3 file.

This works:

  - service: media_player.play_media
    data:
      entity_id: media_player.kabin
      media_content_id: http://resources.schoolscience.co.uk/CDA/CD/files/sound/decorativelamp.mp3
      media_content_type: music

But if I want to use local file - I get nothing.

  - service: media_player.play_media
    data:
      entity_id: media_player.kabin
      media_content_id: https://myduck.duckdns.org:8123/local/sounds/decorativelamp.mp3
      media_content_type: music

I even tried to write this in configuration.yaml but that did not work out again

homeassistant:
  whitelist_external_dirs:
    - '/config/sounds'

If you put that in your web browser, does it work?

Hm, no, it doesn’t

Upd:
Tried to download that file from App (via configurator) and was redirected to chrome. Got unauthorized issue.