diff --git a/cnn_madmom/segment.py b/cnn_madmom/segment.py index b1455c725c49ba52343f77b39094dfea5555f11f..95725517947691c441002c68dd02dd54081d12ce 100644 --- a/cnn_madmom/segment.py +++ b/cnn_madmom/segment.py @@ -35,7 +35,7 @@ def segment(songfile, reference_syls=None, syls_per_line=10, last_syl_dur=500): activation_smoothed = madmom.audio.signal.smooth(activation_function, 20) cnn_smoothed = madmom.audio.signal.smooth(cnn_function, 20) onsets = madmom.features.onsets.peak_picking(activation_smoothed, threshold=0.1, smooth=0) - onsets = np.array([o for o in onsets if cnn_smoothed[o] > 0.1]) + #onsets = np.array([o for o in onsets if cnn_smoothed[o] > 0.1]) invalid_onsets_idx = [] magnitude_window = [2,8] @@ -49,12 +49,14 @@ def segment(songfile, reference_syls=None, syls_per_line=10, last_syl_dur=500): if reference_syls: filtered_onsets = [] + line_index = 0 for line in reference_syls: + line_index += 1 syl_number = len(line) - 1 line_onsets = [o for o in onsets if (o >= line[0][0] and o <= line[-1][0])] line_onsets.sort(reverse=True, key=(lambda x: activation_smoothed[x])) if syl_number > len(line_onsets): - print("WARNING : failed to detect enough onsets in line") + print("WARNING : failed to detect enough onsets in line %d (%d, %d)" % (line_index, line[0][0], line[-1][0])) filtered_onsets += line_onsets[0:syl_number] onsets = np.array(sorted(filtered_onsets)) @@ -161,7 +163,7 @@ if __name__ == "__main__": activation_smoothed = madmom.audio.signal.smooth(activation_function, 20) cnn_smoothed = madmom.audio.signal.smooth(cnn_function, 20) onsets = madmom.features.onsets.peak_picking(activation_smoothed, threshold=0.1, smooth=0) - onsets = np.array([o for o in onsets if cnn_smoothed[o] > 0.1]) + #onsets = np.array([o for o in onsets if cnn_smoothed[o] > 0.1]) invalid_onsets_idx = [] magnitude_window = [2,8] @@ -175,12 +177,14 @@ if __name__ == "__main__": if reference_syls: filtered_onsets = [] + line_index = 0 for line in reference_syls: + line_index += 1 syl_number = len(line) - 1 line_onsets = [o for o in onsets if (o >= line[0][0] and o <= line[-1][0])] line_onsets.sort(reverse=True, key=(lambda x: activation_smoothed[x])) if syl_number > len(line_onsets): - print("WARNING : failed to detect enough onsets in line") + print("WARNING : failed to detect enough onsets in line %d (%d, %d)" % (line_index, line[0][0], line[-1][0])) filtered_onsets += line_onsets[0:syl_number] onsets = np.array(sorted(filtered_onsets))