Sir, I tried the code for GFCC but it showing the error, how to rectify this error.

5 visualizaciones (últimos 30 días)
The code is given below,
[audio, fs1] = audioread('cryrumble.wav');
%sound(x,fs1);
ts1=1/fs1;
N1=length(audio);
Tmax1=(N1-1)*ts1;
t1=(0:ts1:Tmax1);
figure;
plot(t1,audio),xlabel('Time'),title('Original audio');
fs2 = (20/441)*fs1;
y=resample(audio,2000,44100);
%sound(y,fs2);
ts2=1/fs2;
N2=length(y);
Tmax2=(N2-1)*ts2;
t2=(0:ts2:Tmax2);
figure;
plot(t2,y),xlabel('Time'),title('resampled audio');
% % spectrogram(y);
nchan = size(y,2);
for chan = 1 : nchan
%subplot(1, nchan, chan)
spectrogram(y(:,chan), 256, [], 25, 2000, 'yaxis');
title( sprintf('spectrogram of resampled audio ' ) );
end
% Step 2: Frame Blocking
frameSize=1000;
% frameOverlap=128;
% frames=enframe(y,frameSize,frameOverlap);
% NumFrames=size(frames,1);
frame_duration=0.06;
frame_len = frame_duration*fs2;
framestep=0.01;
framestep_len=framestep*fs2;
% N = length (x);
num_frames =floor(N2/frame_len);
% new_sig =zeros(N,1);
% count=0;
% frame1 =x(1:frame_len);
% frame2 =x(frame_len+1:frame_len*2);
% frame3 =x(frame_len*2+1:frame_len*3);
frames=[];
for j=1:num_frames
frame=y((j-1)*framestep_len + 1: ((j-1)*framestep_len)+frame_len);
% frame=x((j-1)*frame_len +1 :frame_len*j);
% identify the silence by finding frames with max amplitude less than
% 0.025
max_val=max(frame);
if (max_val>0.025)
% count = count+1;
% new_sig((count-1)*frame_len+1:frame_len*count)=frames;
frames=[frames;frame];
end
end
% Step 3: Hamming Windowing
NumFrames=size(frames,1);
hamm=hamming(1000)';
windowed = bsxfun(@times, frames, hamm);
% Step 4: FFT
% Taking only the positive values in the FFT that is the first half of the frame after being computed.
ft = abs( fft(windowed,500, 2) );
plot(ft);
%greenwood filterbank
x=0:1000;
fmin=10;
fmax=10000;
K=0.88;
A=fmin/(1-K);
a=log10((fmax/A)+K);
f=A*(10.^((A.*x)-K));
perceived_freq_Fp=(1/a)*(log10((f/a)+K));
%perceived_freq_Fp=(1/a)*(ln((f/a)+K)/ln10);
%perceived_freq_F=A*((10^(ax))-K);
plot(f);
Nofilters=20;
lowhigh=[300 fs2/2];
%Converting to frequency resolution
fres=floor(((frameSize)+1)*f/fs2);
%Creating the filters
for m =2:length(f)-1
for k=1:frameSize/2
if k<fres(m-1)
H(m-1,k) = 0;
elseif (k>=fres(m-1)&&k<=fres(m))
H(m-1,k)= (k-fres(m-1))/(fres(m)-fres(m-1));
elseif (k>=fres(m)&&k<=fres(m+1))
H(m-1,k)= (fres(m+1)-k)/(fres(m+1)-fres(m));
elseif k>fres(m+1)
H(m-1,k) = 0;
end
end
end
%H contains the 20 filterbanks, we now apply it to the
%processed signal.
for i=1:NumFrames
for j=1:Nofilters
bankans(i,j)=sum((ft(i,:).*H(j,:)).^2);
end
end
% Step 6: Nautral Log and DCT
% 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:13));
end
hold off
% save c5 gfcc
g= gfcc;
save g g
load g.mat
X=g;
[IDXi,cg] = kmeans(X,K);
save c41g cg
the error is like this,
> Untitled5
Warning: Ignoring rows of X with missing data.
> In kmeans (line 164)
In Untitled5 (line 134)
Error using kmeans (line 265)
K must be a positive integer value.
Error in Untitled5 (line 134)
[IDXi,cg] = kmeans(X,K);

Respuestas (1)

Walter Roberson
Walter Roberson el 27 de Nov. de 2018
The second parameter to kmeans is the number of clusters . You are passing 0.88

Categorías

Más información sobre Working with Signals en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by