So I have been building some devices based on esp32 (wroom devkits). Had them for a while but always had an intermittent issue with the media_player.
I’m using a MAX98357a board into a 3w speaker and using TTS (Piper) to output notifications. It works often, but also often it gets weird and crackly, and sometimes doesn’t even bother to play audio at all.
Below is a video which includes some of the glitching when playing an mp3 (excuse the choice it’s just the one where I got a glitch whilst recording )
My connections are soldered so it’s not a loose jumper issue. I’ve also tried a small resistor on the data and clock lines as suggested elsewhere. I get the symptoms on both devices I’ve built so far, so it’s not specific to a given build.
It feels like the media player gets “stuck” and so sometimes it simply doesn’t output audio even though the media player is “playing”.
Anyone had similar and got any ideas how to root cause the issue?
I have a few media players setup, they use S3 boards though so have a bit more memory. They are also used for Voice assistant so a slightly different setup.
Anyhow the only way I can get them to successfully play everything that is thrown at them is to do it via music assistant, and have the speakers setup as loosy in the audio settings.
Hmm OK that doesn’t sound promising. Mine are meant to be assistants too - I did get wakeword working, but but sound is even worse when it’s listening so I’ve removed that and working from the ground up.
I do have some WROVER items (which are separately deployed for my LMS players) but it sounds like if you’re having issues with S3 boards then they won’t help - I would guess the media_player component doesn’t use/benefit from SRAM.
On the music assistant side - I use LMS instead of music assistant, but are you saying that music assistant can both stream text-to-speed to your ESP media_players as well as music - and also be used to respond to voice assists?
It also sounds like, if you get better sound via music assistant than the native media player, that it may be more a bitrate issue of some kind?
On my S3 boards the voice assistant with wake word works perfectly, as does playing 75% of the media I ask it to play. Some online radio stations will only play successfully via music assistant. The TTS in voice assistant with wake word is fine, but it only really works well with the S3 n16r8 boards. The S3 boards handle TTS fine.
Use the code from Bigbobbas. This has been working perfectly for a few weeks now. Except the few radio stations I mentioned.
It looks quite similar at issues I have running Voice Assistant on Respeaker Lite that use also I2S. I suspect the I2S implementation is not yet fully working as it should (I have some cracks sometimes before or at end of playing some audios and each time I reflash the ESP !
Ah OK might be worth getting hold of a couple of S3 boards to play.
Having said that, I notice in that yaml it’s using esp-idf framework and media_player. When I tried that previously it said media_player wasn’t supported so I have to use arduino framework.
I notice it’s using a custom audio component so I might give that a try with esp-idf framework see if that makes a difference.
Those examples from gnumpi don’t work anymore for me, the wake word failed to restart so Bigbobas changed the code slightly to the one I linked.
Yes the media player did not work in in earlier versions esp-idf, but it has worked for some time now. I use the beta version of Esphome if makes a difference.
This is my code including the wiring details, and wire colours used.