I'm a beginner programmer! I'm triyng to make a program that takes three audio file from a specific path, then divides this in random slices and save this slices in a new specific path. than the program should take the slices and marge them in random order creating a new audio file with 3 minuts length.
from pydub import AudioSegment
from pydub.utils import make_chunks
from pydub import AudioSegment
from pydub.utils import make_chunks
import random
myaudio = AudioSegment.from_file('Theoretical Girls - You Got Me.mp3')
N_SPLIT = 10 #number of differents lenghts of the slices
chunk_sizes = []
for _ in range(N_SPLIT):
chunk_sizes.append(random.randint(10000, 15000)) #random between this values
for chunk_length_ms in chunk_sizes:
chunks = make_chunks(myaudio,chunk_length_ms)
for i, chunk in enumerate(chunks):
chunk_name = '{0}.mp3'.format(i)
print ('exporting', chunk_name)
chunk.export(chunk_name, format='mp3')
this is my code at the moment. I can slice one audio track in random length chunks but I can't the other things. if you could help me it would be nice!