Here's some simple tools I'm playing with to record and play back with my alsa sound card driver.
arecord -d 10 -f cd -t wav foobar.wav
The parameters tell arecord to record for 10 seconds, use cd quality sampling and save it in wav format.
To play it back, I run:
aplay foobar.wav
The first thing I found was that I could barely hear anything I recorded. After a bit of searching I found this helpful piece of advice. The capture of my microphone was turned way down. Using alsamixer I was able to turn the capture up and enable the microphone boost. It worked great.
My next concern was the size of the file being captured. Capturing for 10 seconds created a 1.7 M file. That means for every minute I recorded something, I could expect my wav file to grow by about 11 M. Granted, I could always compress it later to mp3 or ogg vorbis formats, but it still irked me.
Since I was only recording speech, there is a lot I could do to shrink my data file size. The '-f cd' flag is actually a shortcut for '-f S16_LE -c2 -r44100', which means record using 16 bit unsigned little endian notation, use 2 channels (stereo), with a 44100 Hz sampling rate. The first thing I did was to record on only one channel (Mono instead of stereo).
arecord -d 10 -f S16_LE -c1 -r44100 -t wav foobar.wav
I only have one built-in microphone, so I'm not sure I know what 2 channel recording would mean anyway. This cut the size of my 10 second recording in half (to 862 K).
The next thing I changed was the sampling rate. Since I'm only recording speech, I can get away with a much smaller sampling rate. According to wikipedia, many telephony applications use an 8 kHz sampling rate. So I tried that:
arecord -d 10 -f S16_LE -c1 -r8000 -t wav foobar.wav
This yields a file size of 157 K for a 10 second recording. It doesn't sound the greatest at this level, but its fine enough for those times when you know your going to fall asleep in that meeting. To record without a fixed duration (i.e. run until its killed) just omit the '-d 10' parameter.
No comments:
Post a Comment