spafe.features.spfeats

This module is part of the spafe library and has the purpose of of computing the following spectral stats:
  • meanfreq : mean frequency (in kHz)
  • sd : standard deviation of frequency
  • median : median frequency (in kHz)
  • Q25 : first quantile (in kHz)
  • Q75 : third quantile (in kHz)
  • IQR : interquantile range (in kHz)
  • skew : skewness (see note in specprop description)
  • kurt : kurtosis (see note in specprop description)
  • sp.ent : spectral entropy
  • sfm : spectral flatness
  • mode : mode frequency
  • centroid : frequency centroid (see specprop)
  • peakf : peak frequency (frequency with highest energy)
  • meanfun : average of fundamental frequency measured across acoustic signal
  • minfun : minimum fundamental frequency measured across acoustic signal
  • maxfun : maximum fundamental frequency measured across acoustic signal
  • meandom : average of dominant frequency measured across acoustic signal
  • mindom : minimum of dominant frequency measured across acoustic signal
  • maxdom : maximum of dominant frequency measured across acoustic signal
  • dfrange : range of dominant frequency measured across acoustic signal
  • modindx : modulation index. Calculated as the accumulated absolute difference
    between adjacent measurements of fundamental frequencies divided by the frequency range
  • label : male or female

Todo

  • For module TODOs
  • You have to also use sphinx.ext.todo extension
Reference:
http://ijeee.iust.ac.ir/article-1-1074-en.pdf
spafe.features.spfeats.compute_dom_freqs_and_mod_index(sig, fs, lower_cutoff=50, upper_cutoff=3000, nfft=512, win_len=0.03, win_hop=0.015, win_type='hamming', debug=False)[source]

compute dominant frequencies and modulation index.

Parameters:
  • sig (array) – spectral centroid.
  • fs (int) – spectrum array.
Returns:

(float) spectral spread.

spafe.features.spfeats.compute_fund_freqs(sig, fs)[source]

compute fundamental frequencies.

Parameters:
  • centroid (float) – spectral centroid.
  • spectrum (array) – spectrum array.
Returns:

(float) spectral spread.

spafe.features.spfeats.extract_feats(sig, fs, nfft=512)[source]

Compute the spectral features.

Parameters:
  • centroid (float) – spectral centroid.
  • spectrum (array) – spectrum array.
Returns:

(float) spectral spread.

spafe.features.spfeats.root_mean_square(sig, fs, block_length=256)[source]
spafe.features.spfeats.spectral_bandwidth(sig, fs)[source]
spafe.features.spfeats.spectral_centroid(sig, fs)[source]

compute spectral centroid.

spafe.features.spfeats.spectral_flatness(sig)[source]

compute spectral flatness.

spafe.features.spfeats.spectral_flux(sig, fs)[source]
spafe.features.spfeats.spectral_rolloff(sig, fs, k=0.85)[source]
spafe.features.spfeats.spectral_spread(centroid, spectrum, fs)[source]

Compute the spectral spread (basically a variance of the spectrum around the spectral centroid)

Parameters:
  • centroid (float) – spectral centroid.
  • spectrum (array) – spectrum array.
Returns:

(float) spectral spread.

spafe.features.spfeats.zero_crossing_rate(sig, fs, block_length=256)[source]