How to add silent stretches to MP3 using Python?

kj no.email at please.post
Sun Aug 15 02:25:25 CEST 2010



Here's the problem: I have about 25,000 mp3 files, each lasting,
*on average*, only a few seconds, though the variance is wide (the
longest one lasts around 20 seconds).  (These files correspond to
sample sentences for foreign language training.)

The problem is that there is basically no padding before and after
the sound signal.  I want to prepend about 2 seconds of silence to
each file, and append another silent stretch at the end lasting
either 2 seconds or some multiplier of the duration of the original
file, whichever is greater.

I know that manipulating MP3 audio programmatically is usually not
easy, but this has got to be one of the simplest manipulations
possible, so I'm hoping I'll be able to pull it off with Python.

But I have not had much luck finding a Python library to do this.
If someone knows how to do this, and could give me some pointers,
I'd appreciate it.

TIA!

~K



More information about the Python-list mailing list