dinfo = dir(fullfile(trainDir, '**', ext));
filenames = fullfile({dinfo.folder}, {dinfo.name});
nfiles = length(filenames);
feature = cell(nfiles,1);
[fullparent, label] = fileparts(thisfile);
[~, foldername] = fileparts(fullparent);
[y,fs] = audioread(thisfile);
y = resample(y,15000,32000);
norm = zeros(length(y),1);
if( maxAmp > 1 || maxAmp < 0 )
fprintf('(ampMax) out of bound.');
norm = y*(maxAmp/max(y));
norm = y*((-maxAmp)/min(y));
trainAudio = audio(idx(1:round(P*m)),:) ;
testAudio = audio(idx(round(P*m)+1:end),:) ;
trainLabels = labels(idx(1:round(P*m)),:) ;
testLabels = labels(idx(round(P*m)+1:end),:) ;
aFE = audioFeatureExtractor("SampleRate",fs, ...
"SpectralDescriptorInput","melSpectrum", ...
"spectralCentroid",true, ...
featuresTrain = extract(aFE,trainAudio);
featuresTrain = permute(featuresTrain,[2,1,3]);
featuresTrain = squeeze(num2cell(featuresTrain,[1,2]));
[numFeatures,numHopsPerSequence] = size(featuresTrain{1});
featuresTest = extract(aFE,testAudio);
featuresTest = permute(featuresTest,[2,1,3]);
featuresTest = squeeze(num2cell(featuresTest,[1,2]));
sequenceInputLayer(numFeatures)
lstmLayer(50,"OutputMode","last")
fullyConnectedLayer(numel(unique(trainLabels)))
options = trainingOptions("adam", ...
"Shuffle","every-epoch", ...
"ValidationData",{featuresValidation,labelsValidation}, ...
"Plots","training-progress", ...
net = trainNetwork(featuresTrain,trainLabels,layers,options);