added random cut logic
Browse files
utils.py
CHANGED
@@ -142,6 +142,13 @@ def random_cut_length(audio_data, max_length, sample_rate):
|
|
142 |
else:
|
143 |
return audio_data, max_length
|
144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
|
146 |
def generate_songs(state, randomized = True):
|
147 |
idx= pick_and_remove_one()
|
|
|
142 |
else:
|
143 |
return audio_data, max_length
|
144 |
|
145 |
+
|
146 |
+
length_picked = random.choice(options)
|
147 |
+
start_point = np.random.randint(0, max_length - length_picked)
|
148 |
+
end_point = start_point + length_picked
|
149 |
+
audio_data_cut = audio_data[start_point*sample_rate : end_point*sample_rate]
|
150 |
+
return audio_data_cut, length_picked
|
151 |
+
|
152 |
|
153 |
def generate_songs(state, randomized = True):
|
154 |
idx= pick_and_remove_one()
|