Recording audio under Linux using a shell script

This morning, I wrote a small script to record audio using my USB microphone. I need the audio to be recorded using one channel only and to be compressed as a MP3 file. Here’s the script:

echo "Recording now. Press Ctrl-c to cancel"
rawrec -c 1 -d /dev/dsp1 temp.raw
lame -x -m m temp.raw $1
rm -f temp.raw

This is pretty close to what most GUI applications will do, but it has the benefit that I can taylor it the exact way I want. If I want the files to be automatically moved to a special directory, I can do it easily. If I want the files to be uploaded to my blog automatically, I can do it.

Oh! Did I mention that this script is bug-free? As long as lame and rawrec are bug-free, and they mostly are, I work with perfect software.

Yes, I love scripting. It is friendlier.

Published by

Daniel Lemire

A computer science professor at the Université du Québec (TELUQ).

One thought on “Recording audio under Linux using a shell script”

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax