Skip to content

Instantly share code, notes, and snippets.

@piousdeer
Created June 8, 2021 17:05
Show Gist options
  • Save piousdeer/94b36044e1a8caa2b6c70503f4711912 to your computer and use it in GitHub Desktop.
Save piousdeer/94b36044e1a8caa2b6c70503f4711912 to your computer and use it in GitHub Desktop.
Recognize music playing on your Linux computer via a terminal command
audd() {
api_token=test # get one from https://audd.io or use "test" if you don't mind the rate limits
source="$(pactl info | grep 'Default Sink' | cut -d":" -f2 | cut -c2-).monitor"
echo "Listening..."
ffmpeg -hide_banner -loglevel error -f pulse -i $source -t 7 -y /tmp/audd.ogg || return 1
echo "Uploading..."
curl -s -F api_token=$api_token -F file=@/tmp/audd.ogg https://api.audd.io | jq
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment