Created
July 3, 2016 12:28
-
-
Save gchavez2/53148cdf7490ad62699385791816b1ea 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") |
smkplus
commented
Jun 16, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment