Getting NaN and Inf values after extracting features from Audio files

14 visualizzazioni (ultimi 30 giorni)
Hello,
I am trying to extract audio features from audio files that range from 1 - 30 seconds. When I extract the features using the code below, I get some NaN and Inf valuses which causing errors when I try to classify my files. Can someone help me to find out why this is happending? what causes this issue? or how to slove it? or any other thoughts.
I checked the files and there is nothing wrong with them."played the audio and was working fine"
Thank you everyone
trainingFeatures = cell(1,numel(adsTrain.Files));
windowLength = 512;
overlapLength = 0;
aFE = audioFeatureExtractor('SampleRate',16e3, ...
'Window',hamming(windowLength,'periodic'),...
'OverlapLength',overlapLength,...
'spectralCentroid',true, ...
'spectralCrest',true, ...
'spectralDecrease',true, ...
'spectralEntropy',true,...
'spectralFlatness',true,...
'spectralFlux',false,...
'spectralKurtosis',true,...
'spectralRolloffPoint',true,...
'spectralSkewness',true,...
'spectralSlope',true,...
'spectralSpread',true);
reset(adsTrain);
index = 1;
while hasdata(adsTrain)
data = read(adsTrain);
trainingFeatures{index} = extract(aFE,data); % After extracting the features, some of the valuse are NaN and Inf
index = index + 1;
end
  2 Commenti
Ibrahim A
Ibrahim A il 23 Giu 2020
Not sure what causes it but by applying fillmissing function, it should solve the problem by replacing the NaN values with valid values.
Greg Heath
Greg Heath il 17 Ago 2020
You might also have to deal with Inf!
Hope this helps
Greg

Accedi per commentare.

Risposta accettata

Brian Hemmat
Brian Hemmat il 17 Ago 2020
The features you are extracting (basically statistics about a spectrum) are either not defined or poorly defined for an all-zero input, which is mostly likely what you have at the beginning of your audio signal. Audio signals are sometimes padded with zeros to make they a consistent length. As you mention, you can replace the first couple feature vectors with some placeholder that won't error downstream for your system. Or, you can just disregard the feature vectors that correspond to all-zero input, since there is no relevant information there anyway.
Here is an illustration of what you are encountering:
>> windowLength = 512;
overlapLength = 0;
aFE = audioFeatureExtractor('SampleRate',16e3, ...
'Window',hamming(windowLength,'periodic'),...
'OverlapLength',overlapLength,...
'spectralCentroid',true, ...
'spectralCrest',true, ...
'spectralDecrease',true, ...
'spectralEntropy',true,...
'spectralFlatness',true,...
'spectralFlux',false,...
'spectralKurtosis',true,...
'spectralRolloffPoint',true,...
'spectralSkewness',true,...
'spectralSlope',true,...
'spectralSpread',true);
input = zeros(512,1);
features = extract(aFE,input)
features =
NaN NaN NaN 0 Inf NaN 0 NaN 0 NaN
The equations for the spectral descriptors can be found on the individual reference pages in the Audio Toolbox documentation, or summarized here:
If you look at the algorithms, you will see that many will result in a divide by zero (Inf) or a 0/0 (NaN).

Più risposte (0)

Categorie

Scopri di più su Feature Extraction in Help Center e File Exchange

Prodotti


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by