Disclaimer: This is a unix-oriented approach (although sox is cross-platform and should get it done on windows only as well).
You'll need sox - "the [cross-platform] Swiss Army knife of sound processing programs".
This wrapper perl script, helps you generate any seconds of silence: http://www.boutell.com/scripts/silence.html
$ perl silence.pl 3 silence.wav
silence.pl
is quite short, so I include it here, since it's public domains:
#!/usr/bin/perl
$seconds = $ARGV[0];
$file = $ARGV[1];
if ((!$seconds) || ($file eq "")) {
die "Usage: silence seconds newfilename.wav\n";
}
open(OUT, ">/tmp/$$.dat");
print OUT "; SampleRate 8000\n";
$samples = $seconds * 8000;
for ($i = 0; ($i < $samples); $i++) {
print OUT $i / 8000, "\t0\n";
}
close(OUT);
# Note: I threw away some arguments, which appear in the original
# script, and which did not worked (on OS X at least)
system("sox /tmp/$$.dat -c 2 -r 44100 -e signed-integer $file");
unlink("/tmp/$$.dat");
Then just lame
it:
$ lame silence.wav silence.mp3