make it quiet and create /dev/shm/audio with sox info
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 18 Feb 2020 19:37:41 +0000 (20:37 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 18 Feb 2020 19:38:12 +0000 (20:38 +0100)
audio2mqtt.sh
system/audio2mqtt.service [new file with mode: 0644]

index af23cbb..ee76625 100755 (executable)
@@ -2,9 +2,9 @@
 
 while true ; do
 
-arecord -d 1 -r 96000 /dev/shm/tmp.wav
+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' | tr '\n' ',' | sed 's/[, ]*$//'`
+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/audio2mqtt.service b/system/audio2mqtt.service
new file mode 100644 (file)
index 0000000..b4f0096
--- /dev/null
@@ -0,0 +1,10 @@
+[Unit]
+Description=audio to mqtt
+
+[Service]
+User=dpavlin
+ExecStart=/home/dpavlin/air-quality/audio2mqtt.sh
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target