Created
June 7, 2015 18:44
-
-
Save comzeradd/31e4a1998187e16541e8 to your computer and use it in GitHub Desktop.
Random playlist with crossfaded tracks
This file contains 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
import random | |
from glob import glob | |
from pydub import AudioSegment | |
playlist_songs = [AudioSegment.from_mp3(mp3_file) for mp3_file in glob("*.mp3")] | |
random.shuffle(playlist_songs) | |
playlist = playlist_songs.pop(0) | |
for song in playlist_songs: | |
playlist = playlist.append(song, crossfade=(15 * 1000)) | |
playlist = playlist.fade_out(15) | |
playlist_length = len(playlist) / (1000*60) | |
out_f = open("%s_minute_playlist.mp3" % playlist_length, 'wb') | |
playlist.export(out_f, format='mp3') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment