Skip to content
Advertisement

Split audio files using silence detection

I’ve more than 200 MP3 files and I need to split each one of them by using silence detection. I tried Audacity and WavePad but they do not have batch processes and it’s very slow to make them one by one.

The scenario is as follows:

  • split track whereas silence 2 seconds or more
  • then add 0.5 s at the start and the end of these tracks and save them as .mp3
  • BitRate 192 stereo
  • normalize volume to be sure that all files are the same volume and quality

I tried FFmpeg but no success.

Advertisement

Answer

I found pydub to be easiest tool to do this kind of audio manipulation in simple ways and with compact code.

You can install pydub with

JavaScript

You may need to install ffmpeg/avlib if needed. See this link for more details.

Here is a snippet that does what you asked. Some of the parameters such as silence_threshold and target_dBFS may need some tuning to match your requirements. Overall, I was able to split mp3 files, although I had to try different values for silence_threshold.

Snippet

JavaScript

If your original audio is stereo (2-channel), your chunks will also be stereo. You can check the original audio like this:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement