Output mapping and individual feature extractor parameters
[
returns a second struct, idx
,params
] = info(___)params
. The field names of
params
correspond to the feature extractors with settable parameters.
If the "all"
flag is specified, params
contains all
feature extractors with settable parameters. If the "all"
flag is not
specified, params
contains only the enabled feature extractors with
settable parameters. You can set parameters using setExtractorParams
.
extract
Extract the mel spectrum, mel spectral centroid, and mel spectral skewness from concatenated white and pink noise.
fs = 48e3; aFE = audioFeatureExtractor("SampleRate",fs, ... "melSpectrum",true, ... "SpectralDescriptorInput","melSpectrum", ... "spectralCentroid",true, ... "spectralSkewness",true); features = extract(aFE,[2*rand(fs,1)-1;pinknoise(fs,1)]);
Use info
to determine which columns of the output correspond to which feature. Plot the features separately.
idx = info(aFE); surf(log10(features(:,idx.melSpectrum)),"EdgeColor","none"); view([90,-90]) axis tight title("Mel Spectrum") ylabel("Analysis Frame Number")
plot(features(:,idx.spectralCentroid)) axis tight title("Mel Spectral Centroid") xlabel("Analysis Frame Number")
plot(features(:,idx.spectralSkewness)) axis tight title("Mel Spectral Skewness") xlabel("Analysis Frame Number")
audioFeatureExtractor
ProvidesCreate a default audioFeatureExtractor
object. By default, all feature extractors are disabled.
aFE = audioFeatureExtractor
aFE = audioFeatureExtractor with properties: Properties Window: [1024x1 double] OverlapLength: 512 SampleRate: 44100 FFTLength: [] SpectralDescriptorInput: 'linearSpectrum' Enabled Features none Disabled Features linearSpectrum, melSpectrum, barkSpectrum, erbSpectrum, mfcc, mfccDelta mfccDeltaDelta, gtcc, gtccDelta, gtccDeltaDelta, spectralCentroid, spectralCrest spectralDecrease, spectralEntropy, spectralFlatness, spectralFlux, spectralKurtosis, spectralRolloffPoint spectralSkewness, spectralSlope, spectralSpread, pitch, harmonicRatio To extract a feature, set the corresponding property to true. For example, obj.mfcc = true, adds mfcc to the list of enabled features.
The info
function returns information about enabled feature extractors. To view information about all feature extractors, call info
using the "all"
flag.
[idx,params] = info(aFE,"all")
idx = struct with fields:
linearSpectrum: [1x0 double]
melSpectrum: [1x0 double]
barkSpectrum: [1x0 double]
erbSpectrum: [1x0 double]
mfcc: [1x0 double]
mfccDelta: [1x0 double]
mfccDeltaDelta: [1x0 double]
gtcc: [1x0 double]
gtccDelta: [1x0 double]
gtccDeltaDelta: [1x0 double]
spectralCentroid: [1x0 double]
spectralCrest: [1x0 double]
spectralDecrease: [1x0 double]
spectralEntropy: [1x0 double]
spectralFlatness: [1x0 double]
spectralFlux: [1x0 double]
spectralKurtosis: [1x0 double]
spectralRolloffPoint: [1x0 double]
spectralSkewness: [1x0 double]
spectralSlope: [1x0 double]
spectralSpread: [1x0 double]
pitch: [1x0 double]
harmonicRatio: [1x0 double]
params = struct with fields:
linearSpectrum: [1x1 struct]
melSpectrum: [1x1 struct]
barkSpectrum: [1x1 struct]
erbSpectrum: [1x1 struct]
mfcc: [1x1 struct]
gtcc: [1x1 struct]
spectralFlux: [1x1 struct]
spectralRolloffPoint: [1x1 struct]
pitch: [1x1 struct]
Use the idx
struct to enable all feature extractors on the audioFeatureExtractor
object.
features = fieldnames(idx); for i = 1:numel(features) aFE.(features{i}) = true; end aFE
aFE = audioFeatureExtractor with properties: Properties Window: [1024x1 double] OverlapLength: 512 SampleRate: 44100 FFTLength: [] SpectralDescriptorInput: 'linearSpectrum' Enabled Features linearSpectrum, melSpectrum, barkSpectrum, erbSpectrum, mfcc, mfccDelta mfccDeltaDelta, gtcc, gtccDelta, gtccDeltaDelta, spectralCentroid, spectralCrest spectralDecrease, spectralEntropy, spectralFlatness, spectralFlux, spectralKurtosis, spectralRolloffPoint spectralSkewness, spectralSlope, spectralSpread, pitch, harmonicRatio Disabled Features none To extract a feature, set the corresponding property to true. For example, obj.mfcc = true, adds mfcc to the list of enabled features.
Create an audioFeatureExtractor
to extract the ERB spectrum.
aFE = audioFeatureExtractor("erbSpectrum",true)
aFE = audioFeatureExtractor with properties: Properties Window: [1024x1 double] OverlapLength: 512 SampleRate: 44100 FFTLength: [] SpectralDescriptorInput: 'linearSpectrum' Enabled Features erbSpectrum Disabled Features linearSpectrum, melSpectrum, barkSpectrum, mfcc, mfccDelta, mfccDeltaDelta gtcc, gtccDelta, gtccDeltaDelta, spectralCentroid, spectralCrest, spectralDecrease spectralEntropy, spectralFlatness, spectralFlux, spectralKurtosis, spectralRolloffPoint, spectralSkewness spectralSlope, spectralSpread, pitch, harmonicRatio To extract a feature, set the corresponding property to true. For example, obj.mfcc = true, adds mfcc to the list of enabled features.
The second output argument from info
is a struct
that contains the settable parameters of the individual feature extractors and their current value.
[~,params] = info(aFE)
params = struct with fields:
erbSpectrum: [1x1 struct]
params.erbSpectrum
ans = struct with fields:
NumBands: 43
FrequencyRange: [0 22050]
FilterBankNormalization: "bandwidth"
WindowNormalization: 1
SpectrumType: "power"
If you are using the default parameter values, then the parameters are dynamic and updated when properties they depend on are updated. For example, the default frequency range of the ERB filter bank and the default number of bandpass filters in the ERB filter bank depends on the sample rate. Decrease the sample rate of the audioFeatureExtractor
object and then call info
again.
aFE.SampleRate = 16e3; [~,params] = info(aFE); params.erbSpectrum
ans = struct with fields:
NumBands: 34
FrequencyRange: [0 8000]
FilterBankNormalization: "bandwidth"
WindowNormalization: 1
SpectrumType: "power"
You can modify the individual feature extractor parameters using setExtractorParams
. Set the number of bands to 40
and the spectrum type to "magnitude"
. Call info
to confirm that the parameters are updated.
params.erbSpectrum.NumBands = 40; params.erbSpectrum.SpectrumType = "magnitude"; setExtractorParams(aFE,"erbSpectrum",params.erbSpectrum) [~,params] = info(aFE); params.erbSpectrum
ans = struct with fields:
NumBands: 40
FrequencyRange: [0 8000]
FilterBankNormalization: "bandwidth"
WindowNormalization: 1
SpectrumType: "magnitude"
When you set individual feature extractor parameters, they remain at the set value until you set them to another value or return them to defaults. Return the sample rate of the audioFeatureExtractor
object to its initial value and then call info
. The parameters remain at their set value.
aFE.SampleRate = 44.1e3; [~,params] = info(aFE); params.erbSpectrum
ans = struct with fields:
NumBands: 40
FrequencyRange: [0 8000]
FilterBankNormalization: "bandwidth"
WindowNormalization: 1
SpectrumType: "magnitude"
To return parameters to their default values, call setExtractorParams
and specify no parameters.
setExtractorParams(aFE,"erbSpectrum")
[~,params] = info(aFE);
params.erbSpectrum
ans = struct with fields:
NumBands: 43
FrequencyRange: [0 22050]
FilterBankNormalization: "bandwidth"
WindowNormalization: 1
SpectrumType: "power"
aFE
— Input objectaudioFeatureExtractor
objectaudioFeatureExtractor
object.
idx
— Mapping of requested features with output from extractMapping of requested features with output from extract
, returned as a struct
with field names corresponding to individual feature extractors and field values
corresponding to column indices.
params
— Settable parameters of individual feature extractorsSettable parameters of individual feature extractors, returned as a struct with field names corresponding to individual feature extractors and field values containing parameter specification structs. The parameter specification structs have field names corresponding to settable parameter names and field values corresponding to the current parameter setting.
You have a modified version of this example. Do you want to open this example with your edits?