pyACA: Documentation 0.3.1
Source Code for Audio Content Analysis
Loading...
Searching...
No Matches
Functions
pyACA.FeatureSpectralMfccs Namespace Reference

Functions

 FeatureSpectralMfccs (X, f_s, iNumCoeffs=13)
 computes the MFCCs from the magnitude spectrum (see Slaney)
 
 generateDctMatrix (iNumBands, iNumCepstralCoeffs)
 

Function Documentation

◆ FeatureSpectralMfccs()

FeatureSpectralMfccs ( X,
f_s,
iNumCoeffs = 13 )

computes the MFCCs from the magnitude spectrum (see Slaney)

Parameters
Xspectrogram (dimension FFTLength X Observations)
f_ssample rate of audio data
iNumCoeffsnumber of coefficients to compute (default: 13)
Returns
v_mfcc: mel frequency cepstral coefficients

Definition at line 14 of file FeatureSpectralMfccs.py.

14def FeatureSpectralMfccs(X, f_s, iNumCoeffs=13):
15
16 isSpectrum = X.ndim == 1
17 if isSpectrum:
18 X = np.expand_dims(X, axis=1)
19
20 # allocate memory
21 v_mfcc = np.zeros([iNumCoeffs, X.shape[1]])
22
23 # generate filter matrix
24 H = ToolMfccFb(X.shape[0], f_s)
25 T = generateDctMatrix(H.shape[0], iNumCoeffs)
26
27 for n in range(0, X.shape[1]):
28 # compute the mel spectrum
29 X_Mel = np.log10(np.dot(H, X[:, n]) + 1e-20)
30
31 # calculate the mfccs
32 v_mfcc[:, n] = np.dot(T, X_Mel)
33
34 return np.squeeze(v_mfcc) if isSpectrum else v_mfcc
35
36
37# see function mfcc.m from Slaneys Auditory Toolbox
Here is the call graph for this function:

◆ generateDctMatrix()

generateDctMatrix ( iNumBands,
iNumCepstralCoeffs )

Definition at line 38 of file FeatureSpectralMfccs.py.

38def generateDctMatrix(iNumBands, iNumCepstralCoeffs):
39 T = np.cos(np.outer(np.arange(0, iNumCepstralCoeffs), (2 * np.arange(0, iNumBands) + 1)) * np.pi / 2 / iNumBands)
40
41 T = T / np.sqrt(iNumBands / 2)
42 T[0, :] = T[0, :] / np.sqrt(2)
43
44 return T
Here is the caller graph for this function: