minispec.filters.mel

minispec.filters.mel(sr, n_fft, n_mels=128, fmin=0.0, fmax=None, htk=False, norm=1)[source]

Create a Filterbank matrix to combine FFT bins into Mel-frequency bins

Parameters:
sr : number > 0 [scalar]

sampling rate of the incoming signal

n_fft : int > 0 [scalar]

number of FFT components

n_mels : int > 0 [scalar]

number of Mel bands to generate

fmin : float >= 0 [scalar]

lowest frequency (in Hz)

fmax : float >= 0 [scalar]

highest frequency (in Hz). If None, use fmax = sr / 2.0

htk : bool [scalar]

use HTK formula instead of Slaney

norm : {None, 1, np.inf} [scalar]

if 1, divide the triangular mel weights by the width of the mel band (area normalization). Otherwise, leave all the triangles aiming for a peak value of 1.0

Returns:
M : np.ndarray [shape=(n_mels, 1 + n_fft/2)]

Mel transform matrix

Examples

>>> melfb = minispec.filters.mel(22050, 2048)
>>> melfb
array([[ 0.   ,  0.016, ...,  0.   ,  0.   ],
       [ 0.   ,  0.   , ...,  0.   ,  0.   ],
       ...,
       [ 0.   ,  0.   , ...,  0.   ,  0.   ],
       [ 0.   ,  0.   , ...,  0.   ,  0.   ]])

Clip the maximum frequency to 8KHz

>>> minispec.filters.mel(22050, 2048, fmax=8000)
array([[ 0.  ,  0.02, ...,  0.  ,  0.  ],
       [ 0.  ,  0.  , ...,  0.  ,  0.  ],
       ...,
       [ 0.  ,  0.  , ...,  0.  ,  0.  ],
       [ 0.  ,  0.  , ...,  0.  ,  0.  ]])