Batch time-slice audio

I have written a python script to slice up audio files (in batch if so desired) into smaller slices.

It is available for free download here:

This python script slices audio files into file windows along the length of the file until it reaches the end of the file. It slices by time. By default it will slice a file into 2-second blocks, with each block starting at the end of the next block, and each block output as a separate file (into the folder containing the input file; file output names as per input but with the position in the original file added to the output file name). The default format of the output slices is 16-bit, 48kHz, mono. The user can crush the sample to 8-bit width or have it in medium (16-bit) or high-quality (32-bit). Sample rate can be anywhere from low quality (11025 Hz) to high quality (48000 Hz) – in fact, sample rate can be whatever you want, but your computer may not know how to deal those non-standard rates (e.g., I tested it with 1 Hz, and iTunes died when trying to play it – see the help menu for standard/accepted options [python -h] ). The user can also alter the sample slice length and the overlap slide on the previous slice (e.g., you could slice into 10 second windows with each subsequent window sliding along 1 second to overlap the previous window by 1 second. NB. time is measured in milliseconds, so multiply x-seconds by 1000 to get the desired slice length in seconds). There is an option for stereo output. The script can input and output any format that is supported by ffmpeg**.


  1. gcc
  2. pydub (sudo pip install pydub), see
  3. ffmpeg (brew install libav --with-libvorbis --with-sdl --with-theora)
  4. audioread (sudo pip install audioread)

Example usage: python -i xyz.m4a -f m4a -b 2 -s 11025 -l 10000 python -h

**ffmpeg formats:

NB: the 16bit/mono/44.1kHz sample rate was selected to be compatible with the Analog Elektron Rytm drum machine.

this looks great. what specifically are you using it for? mainly the elektron?

Hi Tehn,

Well, the short answer is “yes, I wrote it to slice up my field recordings into one shots, specifically with the Elektron in mind so I could trigger them with the pads”.

The long answer is “But later realised it could be useful for any sample player, e.g., the Monomes and the Arcs. I have made quite a few field recordings over the years and didn’t want to go through them one by one loading them up to find the good bits, chopping them up and naming them individually, dealing with each file manually (as is the case with something like Ableton). And I couldn’t find anything online that would serve this need. I didn’t want to slice by transients because I wanted something less obviously rhythmic, that is to find the otherwise more unusual rhythms, and I didn’t want to map to a keyboard. For example, like when (in the olden days) a cd or vinyl record would get stuck in an unplanned loop – after a a while, the loop starts to make sense. Or like in Frank Bretschneider’s track from ~2000 (can’t think of the name right now), where it starts out going ‘sicko, sicko, sicko’, then morphs into 'Osick, Osick, Osick, then ‘Mexi, Mexi, Mexi’ then eventually you hear it as ‘Mexico, Mexico, Mexico’.”

an exceptional track. i must post it here for all. thomas brinkmann, right?

1 Like

Brilliant work for finding it. Yes it’s Brinkmann, not Bretschneider. Apologies. The video clip is amazing! I’ve never seen that before. I have it on vinyl, now 15 years old already! Good score…

ah, nice. if i stumbled upon this vinyl somewhere i’d freak out.


This looks great for converting high rate samples to lower rate samples to dump to my EMU sp1200.

I currently use an old PC for this but would like to use my macbook

can somebody quickly explain how python works with this (until i get home) ?

thanks in advance



First install Python. If you are running OS X Yosemite, install the latest version of Xcode developer tools (which has gcc). You will also need to install homebrew. Then do the pip installs and brew installs as per the readme on GitHub for this script.

If you want convert files without cropping them, just request a length that is longer than the file.

To run the script using Python, go into a terminal window, and type:
python path/to/ -i path/to/audiofile/*.format

After hitting enter, the script will process the files with default settings. For help on more detailed options, type:
python path/to/ -h

By using a wildcard (*) all files with this extension will be processed. Extension can be e.g., wav, m4a, mp3 etc.


Thank’s a lot for the instructions.

This looks extremely helpful for me :smile:


I have updated the script. It now outputs reversed slices and glues together the reversed slices to make a reversed-granule output file. This is what it did to a well known track (100 ms slices, with a sliding window of 100 ms so no overlap between slices)

1 Like