How to add silence to multiple mp3 files ?

Hello,
I want to add a silence to the end of each Mp3 file. I have about few thousand files so I cannot add them manually :smiley:.
The length of the silence = the length of mp3 file + 2.
For example: If the length of mp3 file is 10 seconds, the length of silence will be 10 + 2 seconds

I used below code but it didn’t solve my problem. So can you help me to write it, please :stuck_out_tongue: ? Thank you very much ! :smiley:

   (setq silence-duration (+ 10 (random 41)))

    ;; Sequence function
    (defun sseq (sig1 sig2)
      (seq sig1 sig2))

    (abs-env
      (let ((my-silence (s-rest silence-duration)))
        (multichan-expand #'sseq s my-silence)))

Have you tried adding the Trim / Extend Nyquist plugin to a Chain?

See hpw to install a Nyquist plugin.


Gale

I have about few thousand files

And if you export MP3, you’ll have a few thousand lower quality files. Audacity creates new MP3 files when it exports. You’re not really ā€œpatchingā€ or ā€œadjustingā€ the old files. This means Audacity has to go through the compression step again and that means the music quality is going to be a bad combination of old and new sound damage.

People who expect the same quality and file sizes generally are not happy. You can export each file at much higher quality and get around this problem (recommended), but the files are going to be much bigger.

Being obsessive, I only do production in WAV (Microsoft) which has no compression sound damage. Those files are huge.

There are ā€œpureā€ MP3 editors that do work on the original file and have no addition damage.

http://wiki.audacityteam.org/wiki/MP3#re-encode

Koz

Hello,
Yes, I tried it but that plugin only add same length of silence to the end of all files. :slight_smile:

Thank you for show me ! I think I am gonna do production in WAV file :smiley:

OK so for a 10 seconds MP3 you want to add 12 seconds silence, and for a 20 seconds MP3 you want to add 22 seconds silence?

What purpose are the files for? Perhaps there is some other solution.


Gale

I did not mention direct MP3 editors because I don’t think they will easily add silence to files, especially if nguyenguyen wants a different length of silence for each file. Those editors work on cut/copy and paste, or you could record a silent MP3 and join the silent MP3 to another MP3.


Gale

Lines 21 to 23:

;; Save original control values.
(setq start-adjust-control start-adjust)
(setq end-adjust-control end-adjust)

Change that to:

(setf end-adjust (+ (get-duration 1) end-adjust))
;; Save original control values.
(setq start-adjust-control start-adjust)
(setq end-adjust-control end-adjust)

You may also want to change the description of the end adjust control. Perhaps something like:

;control end-adjust "Extend end by 100% +" real "" 0 -100 100

I did not mention direct MP3 editors because I don’t think they will easily add silence to files

They may not. but now that the poster is going to do production in WAV to avoid the compression damage, we’re back to doing it in Audacity.

Koz

That’s fine if the poster knows the files may be much larger than before.


Gale

Hello,
Yes, you are right. The purpose is I will repeat the sentences as soon as I listen them.

Hello,
Thank you for writing the code. It worked but after processing, the length of tracks is same although the original length is different.
I imported a lot of mp3 files to Audacity at once. So for a 10 seconds MP3 you want to add 12 seconds silence, and for a 20 seconds MP3 you want to add 22 seconds silence. How to do it ?

I’ve no idea what that means.

Here is a custom version of the Trim/Add silence plug-in where I have made the changes for you and set the defaults to add ā€œ2 second + the original lengthā€ of silence to the end of the selected track.

Install it and it will appear as ā€œTrim Extend Customā€¦ā€
TrimExtendCustom.ny (4.06 KB)