A simple sinusoidal filter applied in the Mel-frequency domain. Notes ----- Cepstral lifting helps to smooth the spectral envelope and dampen the magnitude of the higher MFCC coefficients while keeping the other coefficients unchanged. The filter function is: .. math::
(mfccs, D)
| 487 | |
| 488 | |
| 489 | def cepstral_lifter(mfccs, D): |
| 490 | """ |
| 491 | A simple sinusoidal filter applied in the Mel-frequency domain. |
| 492 | |
| 493 | Notes |
| 494 | ----- |
| 495 | Cepstral lifting helps to smooth the spectral envelope and dampen the |
| 496 | magnitude of the higher MFCC coefficients while keeping the other |
| 497 | coefficients unchanged. The filter function is: |
| 498 | |
| 499 | .. math:: |
| 500 | |
| 501 | \\text{lifter}( x_n ) = x_n \left(1 + \\frac{D \sin(\pi n / D)}{2}\\right) |
| 502 | |
| 503 | Parameters |
| 504 | ---------- |
| 505 | mfccs : :py:class:`ndarray <numpy.ndarray>` of shape `(G, C)` |
| 506 | Matrix of Mel cepstral coefficients. Rows correspond to frames, columns |
| 507 | to cepstral coefficients |
| 508 | D : int in :math:`[0, +\infty]` |
| 509 | The filter coefficient. 0 corresponds to no filtering, larger values |
| 510 | correspond to greater amounts of smoothing |
| 511 | |
| 512 | Returns |
| 513 | ------- |
| 514 | out : :py:class:`ndarray <numpy.ndarray>` of shape `(G, C)` |
| 515 | The lifter'd MFCC coefficients |
| 516 | """ |
| 517 | if D == 0: |
| 518 | return mfccs |
| 519 | n = np.arange(mfccs.shape[1]) |
| 520 | return mfccs * (1 + (D / 2) * np.sin(np.pi * n / D)) |
| 521 | |
| 522 | |
| 523 | def mel_spectrogram( |