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

Try using an HTTP url for your audio source not HTTPS.

Hi, is the “pop” elimination coded in the custom mqtt download below:

Also, is there somewhe a working pinlayout to work with that binary and using ta DAC MAX98357A?

:slight_smile:

Seen that, but what is lrc an bclk for?

And sorry if it was not clear, but related to the pin question I meant to ask if these were ‘coded’ in the build mentioned above.

Yes. Both MrDiy’s and Aspork42’s fork of the code describe that it’s working. Read through the code of both, they mention the MAX98357A in comments.

Sorry, but that is not an answer to my question. The question is to mrdiy if his code supports an dac and with his code how to connect that dac. I use his now without dac but is disturbs and pops.
Thus do I need those pins with mrdiy his firmware or other?

The quesrion is related to mrdiy’s code and how to connect a dac to his.

Most project that uses I2S and a ESP8266 uses the default ESP8266 built-in I2S hardware/pins.

The ESP8266 pins for I2S output are:
Data bits (SD) = GPIO3/RX0
Data bit-clock (SCK) = GPIO15
Word select (WS) = GPIO2/TX1

Thank you, so what pins are that on a d1 mini (what the project is based on)?

We are slowly getting there?

If both of the mentioned code use default I2S pin settings.

Then one could surmise that the schematic of one is valid for the other.

I like the project. Thinking of building it also :wink:

Hi all,
could anyone please help me with this issue? I can not play files located in the config/www folder. @MrDIY to the rescue pls?
Thanks!

I put my media files in /config/www/local_media/xxx.mp3

The payload for MQTT is “http://10.0.0.125:8123/local/local_media/xxx.mp3

Where 10.0.0.125 is the local Ip address for HA.

Works great!

Nice work Mr DIY. Thanks for your hard work.

There seems to be an issue authenticating with the Mosquitto addon when its installed using the default settings now that it is more integrated with the Home Assistant security system. I could not get this project working using a home assistant user I needed to set up a separate login in the Mosquitto configuration.

Works great now.

I realise the library you are using handles the TTS onboard the ESP8266 so its hard to be critical. But the voice is not exactly user friendly but the playing of mp3 file located locally on HA works very well.

I get a little click before and after playing an mp3 but I’ve ordered a MAX98357A DAC to hook a speaker up to and hopefully I end up with a reasonable quality final product.

Thanks again for sharing.

1 Like

Can someone explain to me why this file is encoded? I’m a bit concerned about just flashing someone’s .bin file. I tried to create the .bin with the source .ino but couldn’t get it to work.

It is the audio file that plays at the beginning when the device connects to Wifi & MQTT.

1 Like

Thanks for the reply!

Any chance you might be able to help me out? I hear the startup sound, but I’m not seeing any entries for this in MQTT.

Better tts quality:

  1. Enabling local http (not https) by installation and configuration of NGINX reverse Proxy.

  2. Http service folder configuration (/config/www)
    "Hosting files
    If you want to use Home Assistant to host or serve static files then create a directory called www under the configuration path (/config). The static files in www/ can be accessed by the following URL http://your.local.ip:8123/local/"

  3. Chache folder for Google tts configuration
    # Text to speech
    tts:
    - platform: google_translate
    language: ‘pl’ (Your language)
    cache: true
    cache_dir: /config/www
    time_memory: 300

  4. Node-RED (install node-red-contrib-fs, node-red-contrib-fs-ops)

  • Calling Google tts on different automation - for me message to Kodi Player (creates file xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_pl_-_google_translate.mp3 in /config/www folder)

  • and automation:


    Watch
    File(S): /config/www
    File Lister
    Start Folder: /config/www
    File Pattern: *.mp3
    Address URL
    var file = msg.payload;
    {
    msg.payload = “http://your.local.ip:8123/local/”+file;
    }
    return msg;
    Delay
    I have set it to 15s, but I think it is necessary to modify it and link it to the *.mp3 size
    File Delete
    Path: /config/www
    Filename: msg.payload

    Thanks MrDIY

1 Like

I did have pop sound at the end of mp3 clip, I added 3 seconds silence at the end of the file , and managed to hear the sound very well without pops :slight_smile:

thank you MrDIY

MrDIY,

Kindly if you have (esp8266_mrdiy_mqtt_local_notifier.bin) with (external I2S DAC enabled) instead of (esp8266_mrdiy_mqtt_local_notifier.ino), I have problem compiling the file

Thank you in Advance :slight_smile:

Hi thanks for this great project ! I’ve made some little modifications on it :

  • Ported to platformio
  • Can be compiled for ESP8266 and ESP32
  • Google Translate TTS added (so a little less “cloudless” but multilingual and better voice than the included ESP8266SAM)
  • This code also allows to switch easily between no DAC (version used by mr DIY) , external DAC or internal DAC (for ESP32).
  • You’ll also find some useful comments for wiring your DAC quickly or to improve the code.
  • Support AAC playback (and may be flac) which is useful for online radio :wink:

I still have some bugs related to the compatibility with of the ESP8266Audio library (these bugs are described in the github’s readme, help is welcome :wink: )

1 Like