how to handle huge volume of audio features
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
hema purad
el 20 de Sept. de 2022
Comentada: hema purad
el 22 de Sept. de 2022
I have to find the cartesian product of audio features. I have selected MFCC, BARKSPECTRUM, PITCH as featues.
and I have 10 classes of 1000 samples in my audio database.
I thought MFCC and BARKSP and PITCH produces each with single line of N, M, Q size features but. these each are generating matrix of data with sizeof 970X14 for MFCC, 970X32 for barksp and 970X1 for pitch ... I thought these 970 rows are for 970 training audio samples . Its not so... and thses features size is changing ... please see my code and tell me how to handle this huge volume of audio data and i need to find the cartesian product of these features and I should get 1 row for 1 audio sample with each feature
clc
clear all
clear variables
close all
%------------------------------------
%Create an audioDatastore
db = fullfile('C:/DBs/AudioDB')
audiodb = audioDatastore(db,'IncludeSubfolders',true,'LabelSource','foldernames');
%------------------------------------
[sample, dsInfo] = read(audiodb);
reset(audiodb)
fs = dsInfo.SampleRate;
windowLength = round(0.03*fs);
overlapLength = round(0.025*fs);
%--------------------------------
allfeatures=[];
labels_allfeatures=[];
%------------------------------------
while hasdata(audiodb)
[audioIn,adsInfo] = read(audiodb);
%------MFCC FEATURES---------------
MFCC1 = mfcc(audioIn,fs,'Window',hamming(windowLength,'periodic'),'OverlapLength',overlapLength);
%--------------BARK FEATURES------------------------------
afe = audioFeatureExtractor('SampleRate',fs, ...
'Window',hamming(windowLength,'periodic'), ...
'OverlapLength',overlapLength, ...
'barkSpectrum',true);
%setExtractorParams(afe,"barkSpectrum","NumBands",64)
BSP1=extract(afe,audioIn);
%save barSp.mat barSp
%------PITCH FEATURES-----------------------------
P1 = pitch(audioIn,fs,'WindowLength',windowLength,'OverlapLength',overlapLength);
%save pit.mat pit
feat=[MFCC1,BSP1,P1];
%------------------------------------------------
voicedSpeech = isVoicedSpeech(audioIn,fs,windowLength,overlapLength);
feat(~voicedSpeech,:) = [];
label = repelem(adsInfo.Label,size(feat,1));
%-------------------------------------------------
allfeatures = [allfeatures;feat];
labels_allfeatures = [labels_allfeatures,label];
end %end of while
save allfeatures.mat allfeatures
save labels_allfeatures.mat labels_allfeatures
%---------------------------------
%%
%Supporting Functions
function voicedSpeech = isVoicedSpeech(x,fs,windowLength,overlapLength)
pwrThreshold = -40;
[segments,~] = buffer(x,windowLength,overlapLength,'nodelay');
pwr = pow2db(var(segments));
isSpeech = (pwr > pwrThreshold);
zcrThreshold = 1000;
zeroLoc = (x==0);
crossedZero = logical([0;diff(sign(x))]);
crossedZero(zeroLoc) = false;
[crossedZeroBuffered,~] = buffer(crossedZero,windowLength,overlapLength,'nodelay');
zcr = (sum(crossedZeroBuffered,1)*fs)/(2*windowLength);
isVoiced = (zcr < zcrThreshold);
voicedSpeech = isSpeech & isVoiced;
end
. plz help me.
0 comentarios
Respuesta aceptada
Gabriele Bunkheila
el 21 de Sept. de 2022
Editada: Gabriele Bunkheila
el 21 de Sept. de 2022
Hi Hema, the general way feature extraction works for signals is that a set of features is extracted for every buffer of samples. The longer the file, the higher the number of buffers fitting across its whole length. This is why you are seeing a variable number of feature row for each audio file - because each audio file has different number of audio samples.
audioFeatureExtractor by default uses hamming windows of 1024 samples (around 23ms at 44.1kHz), overlapping by 512 samples. You can get it to use whatever window length, though usually the length is set based on the type of signal and which type of signal characteristic you think will be most discriminative for your problem.
If you are really looking for only a single row a features per file, then you may want to apply some kind of averaging netric (e.g. mean, median, ...) across the rows of the feat array. In the code above that would happen after the use of isVoicedSpeech, if relevant. For example:
% [...]
feat(~voicedSpeech,:) = [];
feat = median(feat,1);
label = adsInfo.Label; % (no more need to size-extend file label)
% [...]
I hope this helps.
Más respuestas (0)
Ver también
Categorías
Más información sobre Simulation, Tuning, and Visualization en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!