How to check if any audio is currently playing via Terminal?

I actually happened to find the answer recently, and I'll post it here for anyone who might need it:

if [[ "$(pmset -g | grep ' sleep')" == *"coreaudiod"* ]]; then echo audio is playing; else echo no audio playing; fi

I discovered the pmset method from this post, but I added some things to it.