Created
April 3, 2018 09:05
-
-
Save megastef/580ab5b7054d12ddbeaa852df1a7e88b to your computer and use it in GitHub Desktop.
SOX, record sound, output sox stats decibel value as JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script to putput dB level from microphone | |
# output: | |
# {"db": -87.03} | |
# {"db": -86.87} | |
# ... | |
while [ 1 ] | |
do | |
sox -b 32 -e unsigned-integer -r 96k -c 2 -d --clobber --buffer $((96000*2*10)) /tmp/soxrecording.wav trim 0 1 2> /dev/null | |
sox /tmp/soxrecording.wav -n stats 2>&1 >/dev/null | grep "RMS lev dB" | awk '{print "{\"db\": " $4 "}"}' | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment