How do i change my audio data to be the same length for an AudioDataStore
Show older comments
Hi, i am wanting to do a basic knn classifier of the RAVDESS dataset
I am writing a project that will do a knn of speech emotion dataset to test accuracy. the problem im having currently is my files are all different lengths so if i try to concatenate my features to use fitcknn the dimensions are not consistent.
this is what i have so far
%audiodatastore to story all 1440 audio clips
ads = audioDatastore(directory, "IncludeSubfolders",true, 'FileExtensions', '.wav');
ads.Labels = {audioData.emotion};
%shuffle audio data and split into training and testing data
shufAds = shuffle(ads);
[trainSet, testSet] = splitEachLabel(shufAds, 0.8);
% Extract audio features using audioFeatureExtractor
aFe = audioFeatureExtractor('SampleRate', 48000 , ...
'spectralRolloffPoint',true, 'spectralSpread', true,pitch=true);
trainFeatures = extract(aFe, trainSet);
trainLabels = trainSet.Labels;
feat1 = zeros(493, 1152);
feat2 = zeros(493, 1152);
feat3 = zeros(493, 1152);
for i = 1:1152
% Extract spectralRolloffPoint feature
feat1(:, i) = trainFeatures{i}(:, 1);
% Extract spectralSpread feature
feat2(:, i) = trainFeatures{i}(:, 2);
% Extract pitch feature
feat3(:, i) = trainFeatures{i}(:, 3);
end
%kMd = fitcknn(trainFeatures, trainLabels, 'NumNeighbors', 3);
i understand feat1,feat2 and feat3 dont work, the error there is
%Unable to perform assignment because the size of the left side is 493-by-1 and the size of the right side is 327-by-1.
Error in untitled2 (line 61)
feat1(:, i) = trainFeatures{i}(:, 1);`
if anyone could help me out with making my audio all the same length that would be a lifesaver, i dont care at this point whether i truncate or pad, whatevers easiest.
Obvioulsy if my logic so far is completely off, any help would be amazing.
Accepted Answer
More Answers (0)
Categories
Find more on Feature Extraction in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!