bishmoy commited on
Commit
e887be1
·
verified ·
1 Parent(s): 05a6fcb

added random cut logic

Browse files
Files changed (1) hide show
  1. utils.py +7 -0
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()