Sample Header Ad - 728x90

Detecting sound / silence on a sox pipe?

1 vote
2 answers
1584 views
I am trying to keep a sox pipe input from a sound card open and execute a player commend only when there is sound in the pipe (without killing the pipe or using a file). This could be easily achieved with sox silence 1 0.1 5% -1 0.1 5% for files but when I use it for a pipe output it doesn't work. This is the sox record command I'm using
/bin/sox -V2 -q \
-r 48000 -b 16 -c 2 -t alsa hw:CARD=sndrpihifiberry,DEV=0 \
-t wav -r 44100 -b 16 -c 2 - \ 
silence 1 0.1 0.1% -1 2 0.5% \ 
> $streamFile &
I would like to attach and detach a player to the pipe only when there's a sound in the pipe. Something like:
while [ true ]; do 
  
        until [ WAIT FOR  SOUND ]; do
        
        TEST FOR SOUND IN THE PIPE
        
        done
        
        echo "Sound Detected starting @ $(date)" >> $log
        /usr/bin/player > $log

done
Any ideas?
Asked by nadigo (11 rep)
Jan 6, 2022, 11:46 PM
Last activity: Nov 28, 2023, 04:36 PM