Last active
November 6, 2018 22:26
-
-
Save chisler/c94dbd5f2fcc1ea381198c3eadcbed32 to your computer and use it in GitHub Desktop.
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
from pydub import AudioSegment | |
import datetime | |
path = "" | |
sound = AudioSegment.from_mp3(path) | |
length = len(sound) | |
print(f'Length of the file is {datetime.timedelta(milliseconds=length)} How many minutes should be one file?') | |
step_minutes = input() | |
step_miliseconds = int(step_minutes) * 60000 | |
l = 0 | |
c = 0 | |
while l + step_miliseconds < length: | |
sound[l:l+step_miliseconds].export(f"path/file_{c}.mp3", format="mp3") | |
print(f'File_{c}.mp3 created') | |
l += step_miliseconds | |
c += 1 | |
print(f'Count: {c} sounds created') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment