wav = wav.astype("float")
n_fft = 125
hop_length = 125
n_mels = 16
S = librosa.feature.melspectrogram(wav, sr=self.audio_sr, n_fft=n_fft, hop_length=hop_length, n_mels=n_mels)
Which gives:
I wanted to see the correlation between this spectrogram and another variable:
The thing is I would like to know at what frequencies are found the maximum values in this plot, so i would need to know the frequencies [Hz] in each of the 16 mel-bands of the mel-spectrogram.
Would you know if I can get that information from the librosa.feature.melspectrogram() function, or if I can calculate it in some way?
Thank you!
Joaquin
--
You received this message because you are subscribed to the Google Groups "librosa" group.
To unsubscribe from this group and stop receiving emails from it, send an email to librosa+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/librosa/e407ce40-cdac-4c82-91fa-b0e8a1d7e6f9n%40googlegroups.com.
Hello Joaquin and Tiago,
There is a better way :)
Use the function librosa.mel_frequencies
https://librosa.org/doc/main/generated/librosa.mel_frequencies.html
(which is called internally by librosa.filters.mel)
and you will get the frequencies in Hertz.
You can pass the same hyperparameters to librosa.mel_frequencies as those you passed to librosa.melspectrogram
I hope this helps!
Sincerely,
Vincent
To view this discussion on the web visit https://groups.google.com/d/msgid/librosa/CALHB4VQR823JuQwtfytUeSpjTu68CMTZuE-XKYRMaRbzjQazng%40mail.gmail.com.
Hello Joaquin,
> Are those 16 values the bands limits? Should I run it with n_mels = 17 in order to get those 16 bands?
These 16 values are the center frequencies of the bands.
If you want the lower limits, do the following:
> mel_f = mel_frequencies(n_mels + 2, fmin=fmin,
fmax=fmax, htk=htk)
> low = mel_f[:-2]
> center = mel_f[1:-1]
> high = mel_f[2:]
Note the +2 offset to account for the boundaries. This +2 offset
is present in the source code of librosa.filters.mel
https://librosa.org/doc/main/_modules/librosa/filters.html#mel
To view this discussion on the web visit https://groups.google.com/d/msgid/librosa/ce3f8960-c2d6-4e9c-bf96-2d3169ad8d83n%40googlegroups.com.