Can any one please tell me how I can remove this error in MFCC?

Hi there,
I am trying to run the code but not getting the correct plot with the melfilter. And that's why I tried oopp.m to get the curve. But the outout of that oopp.m is 1x12 while that of FFTFreqMat is of 1x501. what should I need to do? Because I want this step for my further code to run.
%============================================================================================
oopp.m
%function [f] = oopp(f2)
f=zeros(1,501);
f1=0;f2=12500;
n=10;
fm1=2595*log10(1+f1/700);
fm2=2595*log10(1+f2/700);
fmw=(fm2-fm1)/(n+1);
fm=fm1:fmw:fm2;
f=700*(exp(fm/1125)-1)
%=========================================================
MFCCProcessor.m
N = 256;
M = 100;
Frames = 1 + floor((length(y) - N)/double(M));
V = zeros(N, Frames);
for n=1:Frames
k = 100*(n-1) + 1;
for j=1:N
V(j,n) = y(k);
k = k + 1;
end
end
W = hamming(N);
WresultMatrix = diag(W)*V;
FreqFFTMatrix = fft(WresultMatrix);
[MelFrequencyVector] = oopp(Fs);
y2 = 1 + floor(N/2);
ms = MelFrequencyVector*abs(FreqFFTMatrix(1:y2)).^2;
%=============================================================
at this point it throws error=>
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform elementwise
multiplication, use '.*'.
Error in MFCCProcessor (line 66)
ms = MelFrequencyVector*abs(FreqFFTMatrix(1:y2)).^2;
Error in phase1 (line 19)
MFCC = MFCCProcessor(y,Fs,i+2);

4 comentarios

Undefined function or variable 'y'.
function phase1out = phase1(folder, n)
K= 20;
files = dir(fullfile(folder,'*.wav'));
audio = cell(1,4);
for i = 1:n
[y,Fs] = audioread(files(i).name);
sound (y,Fs)
MFCC = MFCCProcessor(y,Fs,i+2);
phase1out{i} = vector(MFCC, K);
end
end
That would generate an error about an attempt to call script MFCCProcessor as a function.
Gaurav Sharma
Gaurav Sharma el 29 de Nov. de 2018
Editada: Gaurav Sharma el 29 de Nov. de 2018
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform elementwise
multiplication, use '.*'.
Error in MFCCProcessor (line 66)
ms = MelFrequencyVector*abs(FreqFFTMatrix(1:y2)).^2;
Error in phase1 (line 19)
MFCC = MFCCProcessor(y,Fs,i+2);
this is the error i am getting...... that function is running properly if instead of oopp.m, I used another function.

Iniciar sesión para comentar.

 Respuesta aceptada

N = 256;
[..]
y2 = 1 + floor(N/2);
so y2 will be 1+floor(256/2) which will be 129.
ms = MelFrequencyVector*abs(FreqFFTMatrix(1:y2)).^2;
the first 129 entries from FreqFFTMatrix will be used. When we look at
W = hamming(N);
WresultMatrix = diag(W)*V;
we can see that diag(W) will be a 2D array not a vector, and 2D array * anything has a result that has multiple rows. When we then do
FreqFFTMatrix = fft(WresultMatrix);
we know the output is the same size as the input, so FreqFFTMatrix will have multiple rows. Therefore indexing entries 1:y2 of it will have multiple rows -- a column vector result. (If FreqFFTMatrix had been a row vector then indexing 1:y2 would have given a row vector result.)
Then, abs() of a column vector gives a column vector, and squaring that stays a column vector. Thus the right hand side of
ms = MelFrequencyVector*abs(FreqFFTMatrix(1:y2)).^2;
will have multiple rows and 1 column. In particular it will have y2 = 129 rows. For the * operation to succeed, MelFrequencyVector would have to have the same number of columns that the abs().^2 has rows, so MelFrequencyVector would have to have 129 columns. If the name of the variable is accurate, it would have to be a row vector with 129 columns.
... But is it?
[MelFrequencyVector] = oopp(Fs);
So we look at oopp
%function [f] = oopp(f2)
Well, that is a problem. No function line. You are attempting to access script oopp as if it were a function.
If we say "Oh that's a typo, the % is not really there", then we can proceed,
f1=0;f2=12500;
Look at us ignoring the input value.
With that fixed value of f2, the number of entries returned in the vector is 12.
We can then proceed to try to trace through with a different upper bound f2 expecting that it might give a different number of outputs. However except for degenerate cases like f2 = 0, then it turns out that the logic in that code will return a vector of length n+2 where n=10 is set in the code. n would have to be set to 127 in oopp in order to return a row vector of length 129 to match the 129 entries of y2 so that ms would get down to a scalar.

3 comentarios

Gaurav Sharma
Gaurav Sharma el 29 de Nov. de 2018
Editada: Gaurav Sharma el 29 de Nov. de 2018
I appreciate your help Mr. Walter.
As per asked, I changes the n to 127, but still I am getting same error. When I checked, the FreqFFTMatrix(1:y2)= 1x129 double;
MelFrequencyVector=1x129 double;
I tried doing => MelFrequencyVector*transpose(abs(FreqFFTMatrix(1:y2)).^2)
i got 1x1 result.
Any ways, I take the transpose of MelfrequenctVector, and from that I got 129x129 matrix. But Now, If I am taking dct(log(ms))=> it gives me -inf hence no plot. May I request you to tell me how can overcome this problem?
What size do you need ms to be?
that depends on the speaker speech wave......
actually, when I am trying to use melfilter.m, i am getting DCT plot, but the mel filter triangular bank plot is not correct, while when I use oopp.m isntead if melfilter, I will not DCT but will get mel filter Bank...

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 29 de Nov. de 2018

Comentada:

el 29 de Nov. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by