From e1c3bebc337eae78219134ed5b720ab9283496d8 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Tue, 7 Jan 2020 20:57:52 +0100 Subject: [PATCH] calculate rms using sox on 1s audio snippets I'm using this to monitor rotation of (unused!) 220v fan to capture it's rotation and have indication of air movement --- audio2mqtt.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 audio2mqtt.sh diff --git a/audio2mqtt.sh b/audio2mqtt.sh new file mode 100755 index 0000000..cb7e9f5 --- /dev/null +++ b/audio2mqtt.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +while true ; do + +arecord -d 1 -r 96000 /dev/shm/tmp.wav +time=`date +'%s%N'` +info=`sox /dev/shm/tmp.wav -n stat 2>&1 | sed -e 's/(.*)//' -e 's/: */=/' -e 's/ */_/g' | tr '\n' ',' | sed 's/,$//'` +curl --silent -XPOST http://10.60.0.92:8086/write?db=rot13 --data-binary "fan,dc=trnjanska $info $time" + +done -- 2.20.1