-
-
Save okaysidd/af66509b63573c1f9a4707ad36184643 to your computer and use it in GitHub Desktop.
Cut mp3 file with Python and pydub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/jiaaro/pydub | |
from pydub import AudioSegment | |
files_path = '' | |
file_name = '' | |
startMin = 9 | |
startSec = 50 | |
endMin = 13 | |
endSec = 30 | |
# Time to miliseconds | |
startTime = startMin*60*1000+startSec*1000 | |
endTime = endMin*60*1000+endSec*1000 | |
# Opening file and extracting segment | |
song = AudioSegment.from_mp3( files_path+file_name+'.mp3' ) | |
extract = song[startTime:endTime] | |
# Saving | |
extract.export( file_name+'-extract.mp3', format="mp3") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment