librosa.mel_frequencies

librosa.mel_frequencies(n_mels=128, *, fmin=0.0, fmax=11025.0, htk=False)[source]

Compute an array of acoustic frequencies tuned to the mel scale.

The mel scale is a quasi-logarithmic function of acoustic frequency designed such that perceptually similar pitch intervals (e.g. octaves) appear equal in width over the full hearing range.

Because the definition of the mel scale is conditioned by a finite number of subjective psychoaoustical experiments, several implementations coexist in the audio signal processing literature [1]. By default, librosa replicates the behavior of the well-established MATLAB Auditory Toolbox of Slaney [2]. According to this default implementation, the conversion from Hertz to mel is linear below 1 kHz and logarithmic above 1 kHz. Another available implementation replicates the Hidden Markov Toolkit [3] (HTK) according to the following formula:

mel = 2595.0 * np.log10(1.0 + f / 700.0).

The choice of implementation is determined by the htk keyword argument: setting htk=False leads to the Auditory toolbox implementation, whereas setting it htk=True leads to the HTK implementation.

Parameters:
n_melsint > 0 [scalar]

Number of mel bins.

fminfloat >= 0 [scalar]

Minimum frequency (Hz).

fmaxfloat >= 0 [scalar]

Maximum frequency (Hz).

htkbool

If True, use HTK formula to convert Hz to mel. Otherwise (False), use Slaney’s Auditory Toolbox.

Returns:
bin_frequenciesndarray [shape=(n_mels,)]

Vector of n_mels frequencies in Hz which are uniformly spaced on the Mel axis.

Examples

>>> librosa.mel_frequencies(n_mels=40)
array([     0.   ,     85.317,    170.635,    255.952,
          341.269,    426.586,    511.904,    597.221,
          682.538,    767.855,    853.173,    938.49 ,
         1024.856,   1119.114,   1222.042,   1334.436,
         1457.167,   1591.187,   1737.532,   1897.337,
         2071.84 ,   2262.393,   2470.47 ,   2697.686,
         2945.799,   3216.731,   3512.582,   3835.643,
         4188.417,   4573.636,   4994.285,   5453.621,
         5955.205,   6502.92 ,   7101.009,   7754.107,
         8467.272,   9246.028,  10096.408,  11025.   ])