Getting NaN and Inf values after extracting features from Audio files

13 次查看(过去 30 天)
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 个评论
Ibrahim A
Ibrahim A 2020-6-23
Not sure what causes it but by applying fillmissing function, it should solve the problem by replacing the NaN values with valid values.

请先登录,再进行评论。

采纳的回答

Brian Hemmat
Brian Hemmat 2020-8-17
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).

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Feature Extraction 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by