Skip to content
Extraits de code Groupes Projets
Valider 8e51f6db rédigé par Sting's avatar Sting
Parcourir les fichiers

Change threshold + report missing syllables

parent f37247f8
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!3Madmom
...@@ -35,7 +35,7 @@ def segment(songfile, reference_syls=None, syls_per_line=10, last_syl_dur=500): ...@@ -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) activation_smoothed = madmom.audio.signal.smooth(activation_function, 20)
cnn_smoothed = madmom.audio.signal.smooth(cnn_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 = 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 = [] invalid_onsets_idx = []
magnitude_window = [2,8] magnitude_window = [2,8]
...@@ -49,12 +49,14 @@ def segment(songfile, reference_syls=None, syls_per_line=10, last_syl_dur=500): ...@@ -49,12 +49,14 @@ def segment(songfile, reference_syls=None, syls_per_line=10, last_syl_dur=500):
if reference_syls: if reference_syls:
filtered_onsets = [] filtered_onsets = []
line_index = 0
for line in reference_syls: for line in reference_syls:
line_index += 1
syl_number = len(line) - 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 = [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])) line_onsets.sort(reverse=True, key=(lambda x: activation_smoothed[x]))
if syl_number > len(line_onsets): 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] filtered_onsets += line_onsets[0:syl_number]
onsets = np.array(sorted(filtered_onsets)) onsets = np.array(sorted(filtered_onsets))
...@@ -161,7 +163,7 @@ if __name__ == "__main__": ...@@ -161,7 +163,7 @@ if __name__ == "__main__":
activation_smoothed = madmom.audio.signal.smooth(activation_function, 20) activation_smoothed = madmom.audio.signal.smooth(activation_function, 20)
cnn_smoothed = madmom.audio.signal.smooth(cnn_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 = 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 = [] invalid_onsets_idx = []
magnitude_window = [2,8] magnitude_window = [2,8]
...@@ -175,12 +177,14 @@ if __name__ == "__main__": ...@@ -175,12 +177,14 @@ if __name__ == "__main__":
if reference_syls: if reference_syls:
filtered_onsets = [] filtered_onsets = []
line_index = 0
for line in reference_syls: for line in reference_syls:
line_index += 1
syl_number = len(line) - 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 = [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])) line_onsets.sort(reverse=True, key=(lambda x: activation_smoothed[x]))
if syl_number > len(line_onsets): 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] filtered_onsets += line_onsets[0:syl_number]
onsets = np.array(sorted(filtered_onsets)) onsets = np.array(sorted(filtered_onsets))
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter