How to get rid of error: Error using horzcat. Dimensions of array being concatenated are not consistent.

8 visualizzazioni (ultimi 30 giorni)
I have been working on speaker identification using MFCC and Pitch and after the process of feature extraction of files loaded from database and concatenating them into single array I recieve the error.
My code:
ads= audioDatastore(datadir,'FileExtensions','.wav','LabelSource','foldernames')
fs = dsInfo.SampleRate;
windowLength = round(0.03*fs);
overlapLength = round(0.025*fs);
features = [];
labels = [];
while hasdata(ads)
[audioIn,dsInfo] = read(ads);
melC = mfcc(audioIn,fs,'WindowLength',windowLength,'OverlapLength',overlapLength);
f0 = pitch(audioIn,fs,'WindowLength',windowLength,'OverlapLength',overlapLength);
feat =[melC,f0]; %Error on this line
voicedSpeech = isVoicedSpeech(audioIn,fs,windowLength,overlapLength);
feat(~voicedSpeech,:) = [];
label = repelem(dsInfo.Label,size(feat,1));
features = [features;feat];
labels = [labels,label];
end
M = mean(features,1);
S = std(features,[],1);
features = (features-M)./S;
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
In workspace window
Value for f0 = 442x2 double
Value for melC= 442x14x2 double
  1 Commento
Geoff Hayes
Geoff Hayes il 27 Apr 2020
Smarth - the code is trying to concatenate a 442x2 array with a 442x14x2 array and so the error makes sense. How are you trying to combine the two? What should the dimensions of the concatenated result be?

Accedi per commentare.

Risposte (1)

Srivardhan Gadila
Srivardhan Gadila il 30 Apr 2020
While concatenating arrays, the lengths of the dimensions must match except for the operating dimension.

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by