Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://sox.sourceforge.net/" rel="nofollow noreferrer" title="SoX">SoX</a> is the Swiss Army knife of sound processing. You can utilize it to analyze recordings. The only shortcoming of the folowing solutions is:</p> <ol> <li>You need to split up the recordings to fixed size chunks</li> <li>You can lose recording time (due to killing/analyzing/restarting of recordings) </li> </ol> <p>So further improvements could be doing analyzing asynchronous, although this will complicate the job.</p> <pre><code>#!/bin/bash record_interval=5 noise_threshold=3 storage_folder=~/recordings exec 2&gt;/dev/null # no default error output while true; do rec out.wav &amp; sleep $record_interval kill -KILL %1 max_level="$(sox out.wav -n stats -s 16 2&gt;&amp;1|awk '/^Max\ level/ {print int($3)}')" if [ $max_level -gt $noise_threshold ];then mv out.wav ${storage_folder}/recording-$(date +%FT%T).wav; else rm out.wav fi done </code></pre> <p><strong>Update:</strong></p> <p>The following solution uses a fifo as output from rec. By using split on this pipe to get the chunks, there should be no loss of recording time:</p> <pre><code>#!/bin/bash noise_threshold=3 storage_folder=~/recordings raw_folder=~/recordings/tmp split_folder=~/recordings/split sox_raw_options="-t raw -r 48k -e signed -b 16" split_size=1048576 # 1M mkdir -p ${raw_folder} ${split_folder} test -a ${raw_folder}/in.raw || mkfifo ${raw_folder}/in.raw # start recording and spliting in background rec ${sox_raw_options} - &gt;${raw_folder}/in.raw 2&gt;/dev/null &amp; split -b ${split_size} - &lt;${raw_folder}/in.raw ${split_folder}/piece &amp; while true; do # check each finished raw file for raw in $(find ${split_folder} -size ${split_size}c);do max_level="$(sox $sox_raw_options ${raw} -n stats -s 16 2&gt;&amp;1|awk '/^Max\ level/ {print int($3)}')" if [ $max_level -gt $noise_threshold ];then sox ${sox_raw_options} ${raw} ${storage_folder}/recording-$(date +%FT%T).wav; fi rm ${raw} done sleep 1 done1 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload