How to solve dimension problem
Show older comments
I got script like this and for some reason it works with some audio samples and with other it doesnt.
asc
ascacsSamples have same length exactly same number of samples but for some reason it gives me this error.
%
rm
assignment because the size of the left side is 13-by-1 and the size of the right side
is 3-by-1.
Error in stFeatureExtractionmfcc (line 61)
mfccFeatures(:,i) = zeros(numOfFeatures, 1);
Error in Mfccshoww (line 39)
Curframe{i} = stFeatureExtractionmfcc(frame, fs, 0.09, 0.03);
[Signal, fs] = audioread('long_sample_1.wav');
if (size(Signal,2)>1)
Signal = (sum(Signal,2)/2);% convert to MONO
end
% win = 0.31;
% step = 0.2;
%Testsamplemfcc = stFeatureExtractionmfcc(Signal, fs, win, step);
%spectrum model
% % fs = 44100;
% % T = 1/fs;
% % L = length(Features);
% % f = fs*(0:L-1)/L;
% % t = (0:L-1)*T;
% %
win = 0.31;
%win = 0.310090703; %% length of a single bark match with the window and step
step = 0.1;
curPos = 1;
windowLength = (win * fs);
Stepf = round(step * fs);
d = cell(1,1);
Length_signal = length(Signal);
numberOfFrames = floor((Length_signal-windowLength)/Stepf) + 1;
% = Featuresaudio(1:windowLength);
% % Featuresaudio
% [Features] = getDFT(Featuresaudio, 44100);
Ham = window(@hamming, windowLength);
for i = 1:numberOfFrames
frame = (Signal(curPos:curPos+windowLength-1));
%frame = frame .* Ham;
Curframe{i} = stFeatureExtractionmfcc(frame, fs, 0.09, 0.03);
%Curframe{i} = mean(Curframe{i},2);
Curframe{i} = Curframe{i}; % in case of transposing
d{i}= ((Curframe{i}-mfccFeatures{1}).^2);
d{i} = sum(d{i});
d{i} = sum(d{i},2);
curPos = curPos + Stepf;
end
d = cell2mat(d);
idx = zeros(1,1)
if all(d(:) > 200)
fprintf('Dog wasnt found in any frame')
else
idx = find(d(:) < 170);
%fprintf('Dog detected in frame number %d\n',idx(:))
end
for i = 1:length(idx);
idx(i) = idx(i) *0.1;
end
idx = round(idx,2);
fprintf('Dog detected at second %0.2f\n',idx(:))
Answers (1)
Matt Gaidica
on 13 Dec 2020
0 votes
It appears stFeatureExtractionmfcc() is returning multiple values. What is in that function?
6 Comments
Kamil Kacer
on 13 Dec 2020
Matt Gaidica
on 13 Dec 2020
You would need to provide all the dependencies and your audio sample. This is a mess to debug for you otherwise.
Walter Roberson
on 13 Dec 2020
mfccFeatures(1:13,i) = MFCCs;
That does make the array have at least 13 rows
mfccFeatures(:,i) = zeros(numOfFeatures, 1);
but that tries to assign to only 3 rows.
The difference is that the problem occurs when
if (sum(abs(frame))>eps)
is false. In other words, it happens when there is a frame that is effectively silent but which is not the first frame.
Kamil Kacer
on 13 Dec 2020
Kamil Kacer
on 26 Feb 2021
Walter Roberson
on 26 Feb 2021
No, the situation is undefined, the code can only extract features when features exist, and does not define what the output should be when no features exist.
Categories
Find more on Signal Import and Export 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!