Created
December 18, 2018 00:39
-
-
Save kkabdol/eeab160763e017e70894d05e6da42569 to your computer and use it in GitHub Desktop.
Shortening audio files
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
| import os | |
| from pydub import AudioSegment // https://github.com/jiaaro/pydub | |
| source_dir = "C:\Users\schoe\Desktop\Jukebox\source\\" | |
| destination_dir = "C:\Users\schoe\Desktop\Jukebox\destination\\" | |
| for file in os.listdir(source_dir): | |
| milliseconds = 10*1000 | |
| print( "split \"" + file + "\" from " + source_dir + " into " + destination_dir + " by " + "{:,}".format( milliseconds / 1000 ) + " seconds." ) | |
| song = AudioSegment.from_wav( source_dir + file ) | |
| split = song[:milliseconds] | |
| split.export( destination_dir + file , format="wav") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment