Sir, I tried one code for GFCC and the final matriix is 253x52 but i want 1x52 matrix. and the matrix values are NaN .Why this happening? How to rectify this error?

1 Ansicht (letzte 30 Tage)
The code is givenbelow,
[x,fs1]=audioread('cryrumble.wav');
% ts1=1/fs1;
% N1=length(x);
% Tmax1=(N1-1)*ts1;
% fsu=fs/(N-1);
% t=(0:ts:Tmax);
% f=(-fs/2:fsu:fs/2);
% figure, subplot(411),plot(t,x),xlabel('Time'),title('Original Speech');
% subplot(412),plot(f,fftshift(abs(fft(x)))),xlabel('Freq (Hz)'),title('Frequency Spectrum');
% fs2 = (20/441)*fs1;
% na=resample(audio,2000,44100);
% N2=length(na);
ts1=1/fs1;
N1=length(x);
Tmax1=(N1-1)*ts1;
t1=(0:ts1:Tmax1);
figure;
plot(t1,x),xlabel('Time'),title('Original audio');
fs2 = (20/441)*fs1;
na=resample(x,2000,44100);
%sound(y,fs2);
ts2=1/fs2;
N2=length(na);
Tmax2=(N2-1)*ts2;
t2=(0:ts2:Tmax2);
fsu=fs2/(N2-1);
f=(-fs2/2:fsu:fs2/2);
% Step 1: Pre-Emphasis
a=[1];
b=[1 -0.95];
y=filter(b,a,na);
subplot(413),plot(t2,y),xlabel('Time'),title('Signal After High Pass Filter - Time Domain');
subplot(414),plot(f,fftshift(abs(fft(y)))),xlabel('Freq (Hz)'),title('Signal After High Pass Filter - Frequency Spectrum');
% Step 2: Frame Blocking
frameSize=253;
frame_duration=0.025;
frame_len = frame_duration*fs2;
framestep=0.01;
framestep_len=framestep*fs2;
num_frames =floor(N2/frame_len);
frames=[];
for j=1:num_frames
frame=na((j-1)*framestep_len + 1: ((j-1)*framestep_len)+frame_len);
max_val=max(frame);
if (max_val>0.025)
frames=[frames;frame'];
end
end
% Step 3: Hamming Windowing
NumFrames=size(frames,1);
hamm=hamming(frame_len)';
windowed=[];
for i=1:NumFrames
windowed(i,:)=frames(i,:).*hamm;
end
% Step 4: FFT
for i=1:NumFrames
ft(i,:)=abs(fft((windowed(i,:)),frame_len));
%plot(ft(i,:))
end
%greenwood filterbank
%ftt=padarray(ft,[247,0],0,'post');
filt_num = 52;
kcnst= 253; %nfft
fs=44100;
%elephant sound features between 10hz to 10000hz
fmin= 10;
fmax= 10000;
%A1 and A2 areconstants and x is cochlea position K is cnst equal to 0.88.
greenwoodcnstK= 0.88;
greenwoodcnstA1= fmin/(1-greenwoodcnstK);
greenwoodcnstA2= log10((fmax/greenwoodcnstA1)+greenwoodcnstK);
i=0;
% greenwood frequency
for x = 0 : 0.01 : 1
i=i+1;
freq_grn(i) = (greenwoodcnstA1)*(10^(greenwoodcnstA2 * x)- (greenwoodcnstK));
end
%perceived frequency
for f= 10:1:500;
Fp(f)= (1/greenwoodcnstA2)*log10((f/greenwoodcnstA2)+greenwoodcnstK);
end
for i=1:1:filt_num
f(i)=floor((1024+1)*freq_grn(i)/fs);
end;
% define triangular melbank
for j=2:1:filt_num-1
for i=1:1:kcnst
if i<f(j-1)
h(i,j-1)=0;
elseif f(j-1)<=i && f(j)>=i
h(i,j-1)=(i-f(j-1))/(f(j)-f(j-1));
elseif f(j)<i && f(j+1)>=i
h(i,j-1)=(f(j+1)-i)/(f(j+1)-f(j));
else
h(i,j-1)=0;
end;
end;
end;
figure(3);
plot(h);
%hh=padarray(h,[0,7],0,'post');
for i=1:NumFrames
for j=1:filt_num
bankans(i,j)=sum((ft(i,:).*h(j,:)).^2);
end
end
%pkg load signal
%Here logarithm is of base '10'
logged=log10(bankans);
for i=1:NumFrames
gfcc(i,:)=dct2(logged(i,:));
end
%plotting the GFCC
figure
hold on
for i=1:NumFrames
plot(gfcc(i,1:45));
end
hold off
% save c5 mfcc
i= gfcc;
save i i

Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by