How to split a .wav file into multiple .wav files?

This is a python code snippet that I use for splitting files as per necessity.
I use the pydub library from https://github.com/jiaaro/pydub.
You can modify the snippet to suit your requirement.

from pydub import AudioSegment
t1 = t1 * 1000 #Works in milliseconds
t2 = t2 * 1000
newAudio = AudioSegment.from_wav("oldSong.wav")
newAudio = newAudio[t1:t2]
newAudio.export('newSong.wav', format="wav") #Exports to a wav file in the current path.

Leave a Comment