Google Pixel 2 phones are doing this now as an out-of-the-box feature. It's continuously listening and the song name appears on your lock screen.
https://venturebeat.com/2017/10/19/how-googles-pixel-2-now-p...
https://venturebeat.com/2017/10/19/how-googles-pixel-2-now-p...
Thanks a lot
discussion: https://news.ycombinator.com/item?id=15619416
supported devices: https://wiki.lineageos.org/devices
Personally I've only ever seen "Pixel Ambient Services" show up on my battery list once, and that was 1% usage after a fairly long day out.