I was just about to post this. I have TCL speaker made only for Roku TVs that I bought for $50 and it can do this. Honestly it's the only feature I miss from that soundbar. I'd love to see this feature on my WiiM Amp! It's annoying having to turn down the audio every time there's a transition between a fight scene and regular dialogue. There was a night mode that caps off the loudest sound at a certain point as well as a volume leveling mode that I think prevents too much volume deviation from the baseline audio... Or something like that.
Edit: just found a link to a reddit thread where some people explain it much better than I just did
https://www.reddit.com/r/Roku/s/yJeqBLRmQM