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

Functions

 computeFeature (cFeatureName, x, f_s, afWindow=None, iBlockLength=4096, iHopLength=2048)
 computes a feature from the audio data supported features are: 'SpectralCentroid', 'SpectralCrestFactor', 'SpectralDecrease', 'SpectralFlatness', 'SpectralFlux', 'SpectralKurtosis', 'SpectralMfccs', 'SpectralPitchChroma', 'SpectralRolloff', 'SpectralSkewness', 'SpectralSlope', 'SpectralSpread', 'SpectralTonalPowerRatio', 'TimeAcfCoeff', 'TimeMaxAcf', 'TimePeakEnvelope', 'TimeRms', 'TimeStd', 'TimeZeroCrossingRate',
 
 isSpectral (cName)
 helper functions
 
 isTemporal (cName)
 
 computeFeatureCl (cPath, cFeatureName, bPlotOutput=False)
 main
 

Variables

 parser = argparse.ArgumentParser(description='Compute feature from wav file')
 
 metavar
 
 required
 
 help
 
 args = parser.parse_args()
 
 cPath = args.infile
 
 cFeatureName = args.featurename
 
 bPlotOutput = args.plotoutput
 

Function Documentation

◆ computeFeature()

computeFeature ( cFeatureName,
x,
f_s,
afWindow = None,
iBlockLength = 4096,
iHopLength = 2048 )

computes a feature from the audio data supported features are: 'SpectralCentroid', 'SpectralCrestFactor', 'SpectralDecrease', 'SpectralFlatness', 'SpectralFlux', 'SpectralKurtosis', 'SpectralMfccs', 'SpectralPitchChroma', 'SpectralRolloff', 'SpectralSkewness', 'SpectralSlope', 'SpectralSpread', 'SpectralTonalPowerRatio', 'TimeAcfCoeff', 'TimeMaxAcf', 'TimePeakEnvelope', 'TimeRms', 'TimeStd', 'TimeZeroCrossingRate',

Parameters
cFeatureNamefeature to compute, e.g. 'SpectralSkewness'
xarray with floating point audio data (dimension samples x channels)
f_ssample rate of audio data
afWindowFFT window of length iBlockLength (default: hann)
iBlockLengthinternal block length (default: 4096 samples)
iHopLengthinternal hop length (default: 2048 samples)
Returns
v: feature value
t: time stamps

Definition at line 43 of file computeFeature.py.

43def computeFeature(cFeatureName, x, f_s, afWindow=None, iBlockLength=4096, iHopLength=2048):
44
45 # mypackage = __import__(".Feature" + cFeatureName, package="pyACA")
46 hFeatureFunc = getattr(pyACA, "Feature" + cFeatureName)
47
48 # pre-processing
49 x = ToolPreprocAudio(x)
50
51 if isSpectral(cFeatureName):
52 # compute window function for FFT
53 if afWindow is None:
54 afWindow = ToolComputeHann(iBlockLength)
55
56 assert(afWindow.shape[0] == iBlockLength), "parameter error: invalid window dimension"
57
58 # in the real world, we would do this block by block...
59 [X, f, t] = computeSpectrogram(x, f_s, None, iBlockLength, iHopLength)
60
61 # compute instantaneous feature
62 v = hFeatureFunc(X, f_s)
63
64 if isTemporal(cFeatureName):
65 [v, t] = hFeatureFunc(x, iBlockLength, iHopLength, f_s)
66
67 return v, t
68
69
Here is the call graph for this function:

◆ computeFeatureCl()

computeFeatureCl ( cPath,
cFeatureName,
bPlotOutput = False )

main

Definition at line 90 of file computeFeature.py.

90def computeFeatureCl(cPath, cFeatureName, bPlotOutput=False):
91
92 # read audio file
93 [f_s, afAudioData] = ToolReadAudio(cPath)
94
95 # for debugging
96 iBlockLength = 4096
97 iHopLength = 2048
98
99 # compute feature
100 [v, t] = computeFeature(cFeatureName, afAudioData, f_s, None, iBlockLength, iHopLength)
101
102 # plot feature output
103 if bPlotOutput:
104 plt.plot(t, v)
105
106 return v, t
107
108

◆ isSpectral()

isSpectral ( cName)

helper functions

Definition at line 72 of file computeFeature.py.

72def isSpectral(cName):
73 bResult = False
74 if "Spectral" in cName:
75 bResult = True
76
77 return bResult
78
79
Here is the caller graph for this function:

◆ isTemporal()

isTemporal ( cName)

Definition at line 80 of file computeFeature.py.

80def isTemporal(cName):
81 bResult = False
82 if "Time" in cName:
83 bResult = True
84
85 return bResult
86
87
Here is the caller graph for this function:

Variable Documentation

◆ args

args = parser.parse_args()

Definition at line 122 of file computeFeature.py.

◆ bPlotOutput

bool bPlotOutput = args.plotoutput

Definition at line 125 of file computeFeature.py.

◆ cFeatureName

str cFeatureName = args.featurename

Definition at line 124 of file computeFeature.py.

◆ cPath

str cPath = args.infile

Definition at line 123 of file computeFeature.py.

◆ help

help

Definition at line 115 of file computeFeature.py.

◆ metavar

metavar

Definition at line 114 of file computeFeature.py.

◆ parser

parser = argparse.ArgumentParser(description='Compute feature from wav file')

Definition at line 113 of file computeFeature.py.

◆ required

required

Definition at line 114 of file computeFeature.py.