Skip to content

Instantly share code, notes, and snippets.

@patcon
Created November 1, 2012 17:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patcon/3995368 to your computer and use it in GitHub Desktop.
Save patcon/3995368 to your computer and use it in GitHub Desktop.
Using sox CLI tool to gather metrics on ambient volume in room

Running this on OSX, so need to install sox first:

brew install sox

Then paste this file somewhere, and run it in the background with:

bash monitor-audio-levels.sh

As of right now, it only add a character to /tmp/threshold-tally.txt for every 5-second interval where volume exceeds the arbitrary "3" threshold. Would be really useful to timestamp each, and convert to JSON that we can send to a custom leftronic.com dashboard widget, and get a rough idea of how much of the day a room's volume exceeds a given threshold.

Teams can arrange their dashboard however they please, and line this up with velocity or other metrics. They are free to draw their own conclusions and determine what's in their best interest, and adjust behavior and habits as they set fit. Teams want to do good productive work, and if we have data, we can self-correct. Ideally data will be wiped regularly, at the team's discretion, as it's intended to be only an in-the-moment tool for teams.

References:

#!/bin/bash
record_interval=5
noise_threshold=3
exec 2>/dev/null # no default error output
while true; do
rec out.wav &
sleep $record_interval
kill -KILL %1
max_level="$(sox out.wav -n stats -s 16 2>&1|awk '/^Max\ level/ {print int($3)}')"
if [ $max_level -gt $noise_threshold ];then
echo "." >> /tmp/threshold-tally.txt
else
rm out.wav
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment