# Formula to calculate Cepstral coefficients (not MFCC)

I am currently working with non-audio signals of which I would like to calculate the Cepstrum coefficients with Python so that I can use them with machine learning algorithms. That's probably a quite basic question, but somehow I'm struggling at this point.

I already found some packages in Python that can be used to calculate the MFCCs. However, since these refer to the Mel Frequency, they are unfortunately not suitable for my application.

I already found out that the cepstrum of the signal can be calculated in Python as follows (from this website):

powerspectrum = np.abs(np.fft.fft(signal))**2
cepstrum = np.fft.ifft(np.log(powerspectrum))


That's working so far. But with which formula do I get the (n first) cepstral coefficients?

(I know that I should apply a window function on the signal first - my question is mainly about the approach to calculate the cepstral coefficients)

• Apply DCT, right? – jojek May 2 '18 at 9:03
• Thanks for your help! I found out by now, that there seems to be not a single definition of cepstral coefficients. But applying the DCT to the cepstrum seems to be a common way to get cepstral coefficients. – Frank May 7 '18 at 8:28

Linear Prediction Cepstral Coefficients (LPCC) can easily be computed from LPC (Linear Prediction Coefficients) and I think that a LPC function is implemented in the same package as the MFCC.

All you need to know for extracting $p + 1$ first LPC is here. The formula that link LPC and LPCC is:

$c_0 = ln(p)$

$c_1 = a_1$

$c_i = -a_i + \sum_{n=1}^{i-1}\frac{n}{i}a_{i-n}c_n$ for $1 < i \leq p$

where $c_i$ are the LPCC and $a_i$ the LPC and $p$ the order (i.e. the number of coefficients - 1). I'm not sure about the negative sign before $a_1$. Reference here.

I'm not sure what you mean with 'windowing' but yes it may be necessary depending on your signal and application.

Hope that it will help.

• Thanks for your help! If somebody else is also looking for this: to get the LPC and LPCC, this python package was helpful for me: github.com/RicherMans/pymir – Frank May 7 '18 at 8:16