Simple ESP32 I2S Speaker (old `media_player: i2s_audio`) → how to migrate to new `speaker` platform for basic radio/MP3?

Hi all,

I’m trying to migrate an older ESPHome setup to the new audio system, but I’m running into a lot of issues and confusion.

This is my old (working) configuration:

i2s_audio:
  i2s_lrclk_pin: GPIO19
  i2s_bclk_pin: GPIO18

media_player:
  - platform: i2s_audio
    name: Kippenluik Speaker
    dac_type: external
    i2s_dout_pin: GPIO5
    mode: mono

This worked perfectly for years on an ESP32 with an external DAC.
I could easily play radio streams or MP3s without any problems.


Problem

Now that media_player: i2s_audio is removed, I’m trying to switch to the new:

  • speaker:
  • media_player: speaker

But:

  • The examples in the docs are quite complex (pipelines, TTS, announcements, etc.)
  • I get a lot of errors (invalid options, pipeline errors, unsupported formats)
  • Sometimes I even hit memory issues
  • Even when it compiles, playback often fails

What I actually need (simple use case)

I do NOT need:

  • TTS
  • Assist / voice pipelines
  • announcements

I ONLY want:

  • Play an online radio stream (MP3/AAC URL)
  • OR play a simple MP3 file from a server

Basically the same simple functionality as before.


Questions

  1. What is the simplest possible configuration using the new speaker platform?

  2. Is it possible to disable or bypass the announcement pipeline?

  3. Are there minimal examples that:

    • don’t use TTS
    • don’t require extra components
    • work reliably on standard ESP32 (without PSRAM)?
  4. Has anyone recreated the old i2s_audio behavior with the new system?


Extra context

  • Hardware: ESP32 + external I2S DAC (worked fine before)
  • Old config was lightweight and stable
  • New configs seem much heavier / more complex

At the moment it feels like a big step backwards for simple audio use cases, so I’m probably missing something.

Any minimal working example or guidance would be greatly appreciated.

Thanks!

Speaker Audio Media Player - ESPHome - Smart Home Made Simple - there’s an example config there.

You’ll want the i2s_audio still, and you’ll need speaker as well. Set up the i2s_audio and mixer (not sure if you need this or not - but it does nothing if not needed I believe) platforms and possibly resampler too (only need one if no announcement pipeline). Then, you add the media_player with the speaker platform (don’t need the announcement pipeline or files sections). That should be it. Make sure the media player has a name so HA has it exposed and you can then stream audio to it.

Yes, the new config seems much heavier, but there are significantly fewer problems. You’re not missing anything - it used to be real simple and easy for your simple use case, but other situations either didn’t work or were very buggy. The new format fixes all those at the cost of making it seem more complex for a simple setup… but it’s way more robust and configurable now.

All I can add to the above is there are changes still happening to the esphome media player, and these are likely to be added to sendspin side over the next few esphome versions. How this will affect the media player if not using sendspin I don’t know.

What I am saying is if your player is stilll working wait a bit before updating the code as you may find yourself in the same space next month.

Anyhow there are some working examples here if it helps.

1 Like

my yaml compiles , but i got issues


[11:45:54.037][E][speaker_media_player.pipeline:117]: Media reader encountered an error: ESP_ERR_NOT_SUPPORTED
[11:45:54.040][E][speaker_media_player:362]: The announcement pipeline's file reader encountered an error.
 

Show us your whole yaml.

You said you did not want announcements so why have announcement pipeline?

Did you take a look at this: I²S Audio Speaker - ESPHome - Smart Home Made Simple ?

If you use the i2s_audio media player, migrate to the speaker media player component (the i2s_audio media player has been removed)
i2s_audio:
  i2s_lrclk_pin: GPIO19
  i2s_bclk_pin: GPIO18

speaker:
  - platform: i2s_audio
    dac_type: external
    i2s_dout_pin: GPIOXX

media_player:
  - platform: speaker
    name:  xxxx
    mode: mono

This code got mine working again. I was getting a bunch of different errors before, too. I’m just not sure if you can play MP3s with it. In any case, the voice prompts are working again.

i2s_audio: #MAX98357A
  - id: i2s_out
    i2s_bclk_pin: GPIOXX
    i2s_lrclk_pin: GPIOXX

speaker:
  - platform: i2s_audio
    id: speaker_id
    dac_type: external
    i2s_audio_id: i2s_out
    i2s_dout_pin: GPIOXX
    sample_rate: 16000
    bits_per_sample: 16bit

media_player:
  - platform: speaker
    name: "Speaker Name"
    id: esp_speaker
    announcement_pipeline:
      speaker: speaker_id
      num_channels: 1
      format: WAV
      sample_rate: 16000
    buffer_size: 4000

Note: Based on arduino. Can’t switch to esp-idf due to the bme680 bsec.

@PedroArkanson without at least a resampler, I believe you will run into problems playing anything but a 16bit WAV file. The example configs show how to set both of those up and have the media_player use them instead.

That was the only code that worked for me. I tried it for several days, and it works fine for my TTS announcements. I can’t switch to esp-idf because of the BME680 BSEC. Sure you can increase the sample rate for better sound quality.

cos it required
announcement_pipeline (Required, Pipeline Schema): Configuration settings for the announcement pipeline.

I was curious what that was so went reading - I don’t see it saying where you cannot use esp-idf with the BME680. It seems like BSEC and BSEC2 both should work with either esp-idf or arduino (which I believe was refactored recently to now be on top of esp-idf). Just FYI in case you weren’t aware.

I don’t remember for sure, but it definitely didn’t work because of an error message saying that esp-idf and BSEC aren’t compatible. But it doesn’t really matter, it works for me, and I’m happy with it. :grinning_face_with_smiling_eyes:

Guys, I’ve tried everything, and I’m obviously not the only one for whom it hasn’t worked. This isn’t the first ESP I’ve worked with.

I assume you have read the docs, especially this line “This platform only works on ESP32-based chips using the ESP-IDF framework.”

indeed , but changing this did not work , so i was forced to install an old ephome version in docker to flash i2s speaker without hassle and use my 'old' yaml that worked for years

1 Like

I, too, am trying to update my old working i2c device. After several attempts, this is what worked for me. My trials did not include the on_play, on_pause, on_idle bit which it had in my old code. When I added, I was able to hear playbacks.

i2s_audio:
  - id: i2s_out
    i2s_lrclk_pin: GPIO25
    i2s_bclk_pin: GPIO26

speaker:
  - platform: i2s_audio
    id: output_speaker
    i2s_audio_id: i2s_out
    i2s_dout_pin: GPIO22
    dac_type: external    
    sample_rate: 48000 
    bits_per_sample: 16bit

media_player:
  - platform: speaker
    name: ' '
    id: media_out
    internal: false
    volume_min: 0.4
    volume_max: 0.95
    volume_increment: 0.15    
    announcement_pipeline:
      speaker: output_speaker
      num_channels: 1
      format: WAV
      sample_rate: 48000 
    buffer_size: 6000
    on_play:
      - logger.log: "Playback started!"
    on_pause:
      - logger.log: "Playback paused!"
    on_idle:
      - logger.log: "Playback finished!"
1 Like