danielkrause / DCASE2022-data-generator

Data generator for creating synthetic audio mixtures suitable for DCASE Challenge 2022 Task 3
Other
29 stars 6 forks source link

Potential infinite while loop in metadata_synthesizer.py #4

Closed Molem7b5 closed 1 year ago

Molem7b5 commented 2 years ago

The while loop starting at line 213 of metadata_syntheziser.py has the potential to cause an infinite loop. If np.sum(gaps) > self._total_silence_time_per_layer*10. but all gap values are less than2.*mult_min_gap_len then picked_gaps = np.argwhere(gaps > 2.*mult_min_gap_len) results in len(picked_gaps) == 0 this causes no change to gaps values when gaps[picked_gaps] -= eq_subtract so the loop will carry on infinitely. Below is a minimal example to recreate the issue when using mixture_duration = 15. and event_time_per_layer =10 using source files from NIGEN dataset.

gaps = np.array([16.,10.,18.,10])
total_silence_time_per_layer = 5.0
multi_min_gap_len = 10.

while np.sum(gaps) > self._total_silence_time_per_layer * 10.:
    silence_diff = np.sum(gaps) - self._total_silence_time_per_layer * 10. # silence_diff: 4.0
    picked_gaps = np.argwhere(gaps > 2. * mult_min_gap_len) # what if there are no gaps of this length # picked_gaps: []
    eq_subtract = silence_diff / len(picked_gaps) # eq_subtract: inf
    picked_gaps = np.argwhere((gaps - eq_subtract) > mult_min_gap_len) # picked_gaps: []
    gaps[picked_gaps] -= eq_subtract # gaps: [16., 10., 18., 10]
sreenivasaupadhyaya commented 1 year ago

@Molem7b5 Did you use this code successfully for your application?

danielkrause commented 1 year ago

Thanks for the comment. The problem has been addressed.