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

Testing some stuff

parent f231c971
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!2CNN + Spectral segmentation
...@@ -7,14 +7,42 @@ from scipy.ndimage.filters import maximum_filter ...@@ -7,14 +7,42 @@ from scipy.ndimage.filters import maximum_filter
def segment(songfile): def segment(songfile):
delay = -4
smooth = 20
threshold = 0.4
cnn = madmom.features.onsets.CNNOnsetProcessor() cnn = madmom.features.onsets.CNNOnsetProcessor()
proc = madmom.features.onsets.OnsetPeakPickingProcessor(threshold=0.4, smooth=5, delay=0, fps=100) #proc = madmom.features.onsets.OnsetPeakPickingProcessor(threshold=threshold, smooth=smooth, delay=delay, fps=100)
activation_function = cnn(songfile, num_channels=1) activation_function = cnn(songfile, num_channels=1)
#onsets = proc(activation_function) #onsets = proc(activation_function)
onsets = madmom.features.onsets.peak_picking(activation_function, 0.4, smooth=10)/100 onsets = (madmom.features.onsets.peak_picking(activation_function, threshold, smooth=smooth) + delay)/100
print(onsets) print(onsets)
return onsets return onsets
\ No newline at end of file
if __name__ == "__main__":
songfile = sys.argv[1]
cnn = madmom.features.onsets.CNNOnsetProcessor()
spec = spec = madmom.audio.spectrogram.Spectrogram(songfile, num_channels=1)
log_spec = madmom.audio.spectrogram.LogarithmicSpectrogram(spec, add=1)
activation_function = cnn(songfile, num_channels=1)
#onsets = proc(activation_function)
onsets = madmom.features.onsets.peak_picking(activation_function, 0.4, smooth=20)
print(onsets/100)
fig, axs = plt.subplots(nrows=2, sharex=True)
axs[0].imshow(log_spec.T, origin='lower', aspect='auto')
axs[1].plot(activation_function)
axs[1].vlines(onsets, 0, 1, colors='red')
plt.show()
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter