Turn an ESP8266 WemosD1Mini into an audio notifier for Home Assistant: Play MP3, TTS & RTTL

Do you mean a stutter? That’s what I get when playing TTS through a M5 stack speaker unit (the ones they had in the release party a while back).

Yes, it is stuttering (sometimes crackling) in the first seconds of playback. Then it sounds clean.

edit: is there a way to increase the volume ?

You can get 10 pieces of amplifier board for US $6.99 on Amazon, see - https://www.amazon.com/gp/product/B09YP2Y59K/

i am using the max98357 but i found it still a bit to low.

Hello. This is for anyone else who have setup the native 12c audio as well. I am assuming your setup still works?? I was able to setup a few months ago and got it working. Now, playing mp3 files does not work anymore. No audio coming out of the speaker. However, if I create a tts message, it plays through the speaker. Just not mp3 file. No errors in log either. The url that is shown in the log for the mp3 file will play via a browser. I am stump on how to troubleshoot further.

This is my current config I have posted as a new topic. Using latest version of Esphome v2023.2.2.

hello,

you are right, something changed…

i have one mono and another one stereo and seems the mono has now a low level volume and a poor quality of sound…

the stereo one seems not concerned and still work.

here is the 2 config :

mono:

media_player: 
  - platform: i2s_audio
    name: audionotifier Media Player
    dac_type: external
    i2s_lrclk_pin: GPIO33 
    i2s_dout_pin: GPIO22 
    i2s_bclk_pin: GPIO19
    mode: mono

stereo:

media_player: 
  - platform: i2s_audio
    name: audionotifier stereo Media Player
    entity_category: diagnostic
    dac_type: external
    i2s_lrclk_pin: GPIO33 
    i2s_dout_pin: GPIO22 
    i2s_bclk_pin: GPIO19
    mode: stereo

the stereo version has an external 2x15W amplifier, so maybe the problem is the same but the amplifier do his job…

i think the volume is not so loud than before. Seems something has changed on the level side.

Which kind of speaker do you use @duceduc ? 3Ohms 3W or 4 Ohms 4W or 5 Ohms 5 W?

mine is 3Ohms 3W with the MAX98357a for mono version.

EDIT : the only difference between my 2 config was :

esp32:
  board: esp-wrover-kit
  framework:
    type: arduino

but it doesnt change anything.

there is really a level difference with the new EspHome and same problem with TTS.

We are not alone lol :
https://github.com/esphome/issues/issues/4106

Hey there. I am using this speaker.

Regarding the mono feature. I remembered switching back and forth between stereo and mono and both sounded the same for me when it was working.

I think something changed with this esphome version 2022.12.1.

yep!

perhaps need to make a new ISSUE on github for this?

After some kind of update, TTS stopped stuttering and started working cleanly. Very good for TTS. !!! The radio works the same. But the mp3 stopped working and causes the esp to restart.

Any idea how to connect it to internet radio? :wink:

I get almost everything work. The voice don’t sound good so I’m going to use MP3 files instead.
Where to put them on the server?
I have a own server for Node Read and the Mqtt server. I use raspberry pi with Debian. I can access it from Wan, (I get allot of different data from my locals around in Östergötland :slight_smile: ).

@OlaA

Hello OlaA, congratulation on your fist post.

I put them in www/mk

  • note that mk is folder!!!

then i call the mp3 with:
http://192.168.0.252:8123/local/mk.mp3/name_of_the_file.mp3

this is example of my button that plays one file:

show_name: true
show_icon: true
type: button
tap_action:
  action: call-service
  service: mqtt.publish
  data:
    payload: http://192.168.0.252:8123/local/mk/Крушево_абер_пристигна.mp3
    topic: /speaker_lab/play
  target: {}
entity: person.mqtt_user
icon: mdi:play
name: play

[EDIT]
You can check if your path is ok if you paste the payload into the browser. You should get the player (i use chrome browser)

Can’t get it working. I have flashed Wemos D1 with custom firmware, filled topic with speaker01. I can hear melody from speaker that device successfully connected, however cant play any mp3 from www folder not from automation nor by button kindly posted by you.

button code is following:

show_name: true
show_icon: true
type: button
tap_action:
  action: call-service
  service: mqtt.publish
  data:
    payload: https://192.168.1.20:8123/local/udp.mp3
    topic: /speaker01/play
  target: {}
icon: mdi:play
name: play

Another thing I notice my MQTT integration did not detect device don’t know if it should or not:
image

when I paste web address into browser it works, so I assume something is not right with MQTT connection.

Could you explain to me how to get it working with MP3 over HTTPS? Im using bat file and precompilled bin provided by you.

Hi, Is it possible to play mp3 from internet if we place that specific url?

Any solution on the MP3 issue?

I am using an ESP32 with an external DAC → UDA1334A

My wiring is as follows:

My ESPHOME code is:

esphome:

  name: audio-notifier-1

  friendly_name: audio_notifier_1

esp32:

  board: esp32dev

  framework:

    type: arduino

# Enable logging

logger:

# Enable Home Assistant API

api:

  encryption:

    key: "zEBCe37EmV8ZPmTFlEaWd8BE4YkT45DUVMV0OksMbRU="

ota:

  password: "14a502f63520e30fc336ef966b401601"

wifi:

  ssid: !secret wifi_ssid

  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails

  ap:

    ssid: "Audio-Notifier-1"

    password: "10zAAiH3qVA2"

captive_portal:

i2s_audio:

  i2s_lrclk_pin: GPIO33

  i2s_bclk_pin: GPIO19

media_player:

  - platform: i2s_audio

    name: ESPHome I2S Media Player

    dac_type: external

    i2s_dout_pin: GPIO22

    mode: stereo

I can play TTS without issues but if I play an mp3 file from my home assistant media, it only stutters.

Any solution to this issue? I can see that it was working prior to February of this 2023, and an update might have broken the capability to play mp3 files.

Has anyone found a solution???

1 Like

It plays from HTTP but not HTTPS, also pay attention to file name, should be simple latin without spacing, use underline. Also it does not play high bitrate music. Did you manage to get stereo mode working? Im using two MAX98357A boards, however they work in mono mode.

is that the MQTT setup? Any link to find info about the setup?

I am trying to play a 5 second audio located in the “Media” folder of my HA. I have set up my to Stereo mode and my TTL works fine. It also works in Mono mode.

I need to look into this. The wake up chime from Google nest minis makes me nuts (I only use them as tts announcers)