From: Dobrica Pavlinusic Date: Tue, 18 Feb 2020 19:56:17 +0000 (+0100) Subject: audio2influx - sox info about 1s of audio X-Git-Url: http://git.rot13.org/?p=air-quality;a=commitdiff_plain;h=445307493ff5f2391f081b8882e12a24085896d3 audio2influx - sox info about 1s of audio --- diff --git a/README b/README index d8b6ab1..65b31d5 100644 --- a/README +++ b/README @@ -25,3 +25,11 @@ which uses https://github.com/dpavlin/mq7-co-monitor/ on Arduino to produce output which is then fed to dsm501.pl. +Another strage one is audio2influx.sh which doesn't require +any external hardware but instead report sox info about 1s +or audio to influxdb. I'm using this to passivly monitor +fan rotation by connecting it directly to microphone input +on netbook and adjusting input gain to prevent clipping +using alsamixer. + +To make alsamixer work, I had to remove pulseaudio. diff --git a/alsamixer-left-53-70.png b/alsamixer-left-53-70.png new file mode 100644 index 0000000..af574ff Binary files /dev/null and b/alsamixer-left-53-70.png differ diff --git a/audio2influx.sh b/audio2influx.sh new file mode 100755 index 0000000..ee76625 --- /dev/null +++ b/audio2influx.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +while true ; do + +arecord -d 1 -r 96000 /dev/shm/tmp.wav 2>/dev/null +time=`date +'%s%N'` +info=`sox /dev/shm/tmp.wav -n stat 2>&1 | grep '[0-9][0-9][0-9]*$' | sed -e 's/[()]//g' -e 's/: */=/' -e 's/ */_/g' | tee /dev/shm/audio | tr '\n' ',' | sed 's/[, ]*$//'` +curl --silent -XPOST http://10.60.0.92:8086/write?db=rot13 --data-binary "fan,dc=trnjanska $info $time" + +done diff --git a/audio2mqtt.sh b/audio2mqtt.sh deleted file mode 100755 index ee76625..0000000 --- a/audio2mqtt.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -while true ; do - -arecord -d 1 -r 96000 /dev/shm/tmp.wav 2>/dev/null -time=`date +'%s%N'` -info=`sox /dev/shm/tmp.wav -n stat 2>&1 | grep '[0-9][0-9][0-9]*$' | sed -e 's/[()]//g' -e 's/: */=/' -e 's/ */_/g' | tee /dev/shm/audio | tr '\n' ',' | sed 's/[, ]*$//'` -curl --silent -XPOST http://10.60.0.92:8086/write?db=rot13 --data-binary "fan,dc=trnjanska $info $time" - -done diff --git a/system/audio2influx.service b/system/audio2influx.service new file mode 100644 index 0000000..670f9d4 --- /dev/null +++ b/system/audio2influx.service @@ -0,0 +1,10 @@ +[Unit] +Description=audio to influx + +[Service] +User=dpavlin +ExecStart=/home/dpavlin/air-quality/audio2influx.sh +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/system/audio2mqtt.service b/system/audio2mqtt.service deleted file mode 100644 index b4f0096..0000000 --- a/system/audio2mqtt.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=audio to mqtt - -[Service] -User=dpavlin -ExecStart=/home/dpavlin/air-quality/audio2mqtt.sh -Restart=on-failure - -[Install] -WantedBy=multi-user.target