% given a speech vector, extracts frames and cepstrum coefficients. % based on code originally by Laine & Mark, 2002 function ceps = featurize(signal); al = 160; % 20 ms ul = 80; % 10 ms n = 10; signal = signal'; frame=signal(1:al); % evaluate the number of frames and add zeros at the end to ensure that every frame has the same length N=ceil((length(signal)-ul-1)/ul); zer=N*ul+al-length(signal); signal=[signal zeros(1,zer)]; % extract the frames and store them in the matrix frame for i=1:1:N frame=[frame; signal((ul*i+1):(ul*i+al))]; end a = -real(lpc(frame.',n)); ceps=[]; % initializing h(0) with log(G)=0 (since G=1) % calculation of h according to formula 6.119 of the course book a=a(:,2:size(a,2)); % dropping the first column to get confirm with the notation in the book a(1) belongs now to x[n-1] for n=1:1:size(a,2) summ=zeros(size(a,1),1); % helpvariable for the sum for k=1:1:n-1 summ=summ+k/n*ceps(:,k).*a(:,n-k); end ceps=[ceps (a(:,n)+summ)]; end