I have a bunch of mp3 files containing lots (about 300 per file) of small (0.5s to 3s long) snippets of audio separated by 1s of silence.

I want to edit these mp3 files (preferably losslessly) so that the silent portion of 1s gets replaced by a period of silence as long as the previous audio snippet + 2s. Example:

Current state of the file:

2.3s audio
1.0s silence
1.7s audio
1.0s silence
0.9s audio
1.0s silence


2.3s audio
4.3s silence
1.7s audio
3.7s silence
0.9s audio
2.9s silence

What ways are there to achieve this? I'm open for all kinds of suggestions. (GUI application, command line tool, shell script, whatever...)

  • Any recommendation on a language? Are there languages particularly suited for audio processing? Or can you recommend some library which is capable of this?
    – tajmahal
    Feb 11 '17 at 12:26
  • 1
    audio is usually done in c or c++, but in this case performance is not an issue. so use whatever you like that has a library for reading and writting wave files.
    – Scorb
    Feb 11 '17 at 15:36
  • I'd recommend using Matlab or Octave. Solving this task would be rather trivial in these environments and probably among the most effective methods. The procedure would be something like: 1. store all snippets individually, 2. create a new vector of zeros with the correct length, 3. successively write individual snippets at the correct position in the new vector (leaving a 'pause' of your desired length between them). Most challenging would be to implement the detector to find snippets within a file, but even that requires probably only 5 lines of code at most.
    – S. R.
    Jan 11 '18 at 15:45
  • You might not need a script to do this; Sox has some mechanism for detecting silence.
    – user9881
    Mar 19 '18 at 20:24

This is rather complicated but can be done with some effort ...

Cubase 5 has a feature called Detect silence (page 216) that will mark or split the file for you automagically - from there you will be able to shorten the events & move each event by hand ...

then you can design a macro command that will separate each event from the last using the selected event witch will require selecting each separate event and pressing a button ...


Transport - Location to selection

Edit - Insert silence

then grab all of the events and drag them to the start of the grid ...

Jobs that ant workers do ...


This is well within Audacity's capabilities. Make sure you get it (free) from the official site. There are a lot of sites packing adware and worse with the application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.