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

Functions

 FeatureSpectralKurtosis (X, f_s)
 computes the spectral kurtosis from the magnitude spectrum
 

Function Documentation

◆ FeatureSpectralKurtosis()

FeatureSpectralKurtosis ( X,
f_s )

computes the spectral kurtosis from the magnitude spectrum

Parameters
Xspectrogram (dimension FFTLength X Observations)
f_ssample rate of audio data
Returns
vsk: spectral kurtosis

Definition at line 14 of file FeatureSpectralKurtosis.py.

14def FeatureSpectralKurtosis(X, f_s):
15
16 isSpectrum = X.ndim == 1
17 if isSpectrum:
18 X = np.expand_dims(X, axis=1)
19
20 k = np.arange(0, X.shape[0])
21 # get spectral centroid and spread (mean and std of dist)
22 vsc = FeatureSpectralCentroid(X, f_s) * 2 / f_s * (X.shape[0]-1)
23 vss = FeatureSpectralSpread(X, f_s) * 2 / f_s * (X.shape[0]-1)
24
25 norm = X.sum(axis=0)
26 norm[norm == 0] = 1
27 vss[vss == 0] = 1
28
29 # compute kurtosis
30 vsk = np.zeros(X.shape[1])
31 for n in range(0, X.shape[1]):
32 vsk[n] = np.dot((k - vsc[n])**4, X[:, n]) / (vss[n]**4 * norm[n])
33
34 return np.squeeze(vsk - 3) if isSpectrum else (vsk - 3)