Getting NaN and Inf values after extracting features from Audio files

14 ビュー (過去 30 日間)
Ibrahim A
Ibrahim A 2020 年 6 月 23 日
コメント済み: Greg Heath 2020 年 8 月 17 日
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.
Greg Heath
Greg Heath 2020 年 8 月 17 日
You might also have to deal with Inf!
Hope this helps
Greg

サインインしてコメントする。

採用された回答

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 Center および File ExchangeFeature Extraction についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by