LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   VOX Recorder and Audio Timer Recorder? (http://www.linuxquestions.org/questions/linux-software-2/vox-recorder-and-audio-timer-recorder-598535/)

devmoc 11-10-2007 04:06 AM

VOX Recorder and Audio Timer Recorder?
 
Hello all. I'm looking for a VOX (voice operated) recording application for Linux. I want to record only when audio is coming in from the Line In, not during the dead air times.

I'm also looking for an application that will record audio on a timer basis coming from the Line In. Something like a VCR for audio that I can schedule or just set for xx hours.

I can't find anything on all the usual spots, Sourceforge, Freshmeat, KDE apps, etc. Anyone have any suggestions? Thanks.

matthewg42 11-10-2007 10:01 PM

The package sox provides an audio recording program, rec, which can be triggered by the lack of, and stop recording on detection of silence.

Here's a command which does this:
Code:

rec recording.wav silence 1 5 2% 1 0:00:02 2%
This will record as soon as non-silence is detected (with a 2% volume threshold). The recording will cease when silence is detected for 2 seconds or more.

Note that the program terminates when silence is detected, so if you wanted the program to listen for a second chunk of audio and continue the recording, you would have to call rec from a loop. This is fine, except that it will truncate the file it records to if you use the same file the next time.

One solution is to create a different file for each recording. This might be exactly what you want. If so, it's pretty easy to write a little script to do this. I added in recording for only an hour too, although it will continue to record if there is no silence after the last rec instance is started even if that goes over an hour.
Code:

#!/bin/bash

main () {
        # handle control-c better than just letting sox exit current rec.
        trap sighandler INT

        if [ $? -ne 0 ]; then
                usage 1
        fi

        if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
                usage 0
        fi

        n=1
        while [ $(( $SECONDS / 3600 )) -lt $1 ]; do
                file=recording_$(printf "%03d" $n).wav
                rec $file silence 1 5 2% 1 0:00:02 2%
                let n+=1
        done
}

usage () {
        cat << EOD
Usage:
  $0 hours

where hours is the time to record
EOD
        exit ${1:-0}
}

sighandler () {
        exit "That's all folks."
        exit 2
}

main "$@"


matthewg42 11-10-2007 10:03 PM

If you want to append to the same file, it is possible. You will need to record in raw format, and send the output to stdout, appending with shel re-direction to the file. After all the recording is finished, then you would need to convert the raw format into something more suitable.

This is necessary because .way files and other audio formats include a header at that start of each file. If you simple append wav files together, the resulting file is technically invalid, although it will probably play in most software with the output making a loud pop or squeak or click each time a header is encountered in the middle of the file.

matthewg42 11-10-2007 10:04 PM

The application rezound also has a threshold recording feature, but it crashed when I tried to use it. YMMV.

devmoc 11-11-2007 02:40 AM

Thanks for the response! Rezound looked promising but crashes on me as well. I was hoping to make one continuous wav file. Rezound can probably do this. Is there anyway to make Audacity use a threshold detection?

navaburo 09-25-2009 11:38 AM

squeching app
 
I had the same problem and no acceptable solution (rezound trainwrecked for me too, and though I'm thankful for the bash script Matt, it often cut off the beginnings of dictations), so I wrote a simple C++ program to handle this. It uses a ring-buffer to ensure that the beginnings of non-silent sections of audio do not get cut-off.

Right now the program uses hard-coded sensitivity levels (you have to recompile to adjust them), and it only works with unsigned 8-bit mono. However, little work will be required to add any other (raw) audio format, I just don't have the know-how to work with 16-bit. If anyone manages to add such support, please let me know!

You can grab the code from here:
http://hotwigati.wordpress.com/2009/...ilence-filter/

devmoc 10-23-2009 11:55 PM

navaburo,

I just happened to check this thread at random and see you posted something. Since I made this post I eventually found out something that works for me. It's just a simple script. It works almost perfectly, the only caveat is that you need to have some sound at the very beginning after you run it, otherwise it will keep the first stretch of silence after running it. If you make a noise at the beginning then it's not a problem. You can modify the silence thresholds as necessary as well as the pipe to lame. One final note, if you are using pulseaudio, you may need to get rid of the "-D" device name, just setup your source and check the pulseaudio VU meter to make sure audio is being routed properly then run the script and it should record from that source.

Code:

#!/bin/bash
#USAGE:  ./VOX_Scanner_Recording.sh xxx output.mp3
#USAGE:  Records from line-in for xxx seconds to output.mp3, or Ctrl-C to end recording early, then detects silence and splits tracks and combines into one file
TIME=$1
OUTPUT=$2
arecord -D plughw:0,0 -f S16_LE -c1 -r22050 -t raw -d ${TIME} | lame -r -s 22.05 -m m -b 64 - ${OUTPUT} ;
sleep 3 ;
mp3splt -s -p th=-30,min=1,rm ${OUTPUT} ;
sleep 2 ;
mv ${OUTPUT} ${OUTPUT}.original ;
sleep 2 ;
mpgjoin *.mp3 -o Joined_Output.mp3 ;
sleep 2 ;
rm Track*.mp3 ;



All times are GMT -5. The time now is 02:23 AM.