Splitting an MP3 file by content
June 12, 2023 10:14 AM   Subscribe

I've got an MP3 file with a lot of small clips of audio each separated by 1 second of complete silence. I'd like to split the file into one file for each clip.

In the past I've done this by done this by writing a python script that saved a timestamp every time I hit the spacebar and then listening to whole file and tapping appropriately. Once I have the timestamps splitting the file is trivial.

However, the files are getting larger and doing it that way is getting tedious. I'm looking for a clever method or better yet pre-existing software.
posted by Tell Me No Lies to Technology (10 answers total) 6 users marked this as a favorite
 
This should be pretty straightforward to detect silence and split the file. I haven't used it in a while but librosa almost certainly has a function for this.

https://librosa.org/doc/main/generated/librosa.effects.split.html

https://medium.com/@vvk.victory/audio-processing-librosa-split-on-silence-8e1edab07bbb
posted by TwoWordReview at 10:23 AM on June 12, 2023


Looks like Audacity should have this built in (it's a great open-source editor in general).
posted by trig at 10:24 AM on June 12, 2023 [2 favorites]


Best answer: Maybe this Splitter app?
posted by yerfatma at 10:24 AM on June 12, 2023


Response by poster: I'm not sure how I missed WavePad but it does the trick.

Audacity will select by silences but I couldn't work out how to split the selections automatically.
posted by Tell Me No Lies at 10:28 AM on June 12, 2023


Audacity will select by silences but I couldn't work out how to split the selections automatically.

Just for future reference, this worked for me:
- select the entire track
- Analyze -> Silence Finder (or Sound Finder) to insert labels between sections
- File -> Export -> Export Multiple, with "Split files based on: Labels"
posted by trig at 11:26 AM on June 12, 2023 [2 favorites]


Audacity was a great open-source editor but its new owners are kinda hrrmph.

If you're likely to do this a lot, sox is scriptable. There's even a howto: SoX tutorial: Split by silence. Sox might be picky about mp3 silence being not exactly complete digital silence, and the syntax to split silence from the start and end makes people cry, but it does work.
posted by scruss at 11:33 AM on June 12, 2023


Oh no, I had no idea! Hopefully a fork is in the works...
posted by trig at 11:49 AM on June 12, 2023


Another great tool for editing MP3's is Fission by Rogue Amoeba. Its Smart Split Tool will do this.

It's the only way I know to do lossless MP3 editing. That is, it edits the MP3 without expanding to WAV and then recompressing to MP3, so it doesn't lose a generation of compression quality.
posted by hovey at 11:56 AM on June 12, 2023


@trig, personally I use Dark Audacity which is not just the dark theme but also (I gather but can't swear to) a safer version.
posted by forthright at 2:50 PM on June 12, 2023


My weapon of choice for all things audiovisual is ffmpeg, and sure enough, it has a nicely tweakable silence detection filter.

If your problem were my problem, then if I only had to do it once I'd use Audacity. But if I knew I was going to need to do this more than a handful of times, I'd be writing a script that used ffmpeg's silencedetect filter to generate log output, pipe that log output through some minimal and horribly fragile parser to extract the silence timings, then invoke ffmpeg again using the extracted timings to split and trim my output files exactly as I wanted them.

Then I'd set that script up so as to allow just dragging and dropping audio files onto it, which would make it generate a subfolder full of split-by-silence pieces next to each input file with no further interaction.

the [sox] syntax to split silence from the start and end makes people cry

ffmpeg's command line syntax says "Hold my beer"... so although I wouldn't mind making your problem my problem, I'd want to be sure you weren't happy with your existing solutions first.
posted by flabdablet at 10:54 PM on June 12, 2023 [1 favorite]


« Older 1 month out West and it's a big world   |   Detroit to Toronto -- would you take the bus or... Newer »

You are not logged in, either login or create an account to post comments