Last active
April 6, 2021 06:53
-
-
Save manmohan24nov/03f6a63f8c8b38aaf547c009ed7e71a8 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 | |
mp3_audio = AudioSegment.from_file(r"audio_full.wav", format="wav") | |
print(len(mp3_audio)/(1000*60)) | |
# 12 Minutes audio breaks into 3 minutes 4 audio files (slicingis done by milliseconds) | |
counter_audio = 180 | |
split_audio = [mp3_audio[:180*1000]] | |
for i in range(4): | |
split_audio.append(mp3_audio[counter_audio*1000:(counter_audio+180)*1000]) | |
counter_audio += 180 | |
count = 0 | |
# # lets save it! | |
for count, audio_object in enumerate(split_audio): | |
count += 1 | |
with open(f"{count}_audi_file.wav", 'wb') as out_f: | |
audio_object.export(out_f, format='wav') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment