Sir, I tried a matlab code for finding LPC coefficient and formant frequency of a audio but the program showing error. How to correct the error? The error is like this"Error using .* Matrix dimensions must agree. Error in lpcfinal (line 12) frame"
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
The code is given below,
startIndex=round(56000);
[y, fs] = audioread('wildboar.wav');
preemph = [1 0.63];
z= filter(1,preemph,y);
time=(1:length(z))/fs;
frameSize=floor(44*fs/1000);
endIndex=startIndex+frameSize-1;
frame = z(startIndex:endIndex);
frameSize=length(frame);
frame2=frame.*hamming(length(frame));
spectral=20*log10(abs(fft(frame2)));
len=length(spectral);
ncoeff=8;
a=lpc(frame2,ncoeff);
[h,f]=freqz(1,a,512,fs);
subplot(3,1,1);
plot(time,y); title(y); axis tight
ylim=get(gca, 'ylim');
line([time(startIndex), time(startIndex)], ylim, 'color', 'r');
line([time(endIndex), time(endIndex)], ylim, 'color', 'r');
axis xy
% xlabel('s');
% ylabel('
subplot(3,1,2);
xj=(1:len/2)*fs/len;
plot(xj,spectral(1:len/2));
axis xy
% xlabel('frequency/Hz');
% ylabel('magnitude/dB');
subplot(3,1,3);
plot(f,20*log10(abs(h)+eps));
legend('LPC');
% xlabel('frequency(Hz)');
% ylabel(magnitude(dB)');
r=roots(a);
r=r(imag(r)>0.01);
ffreq=sort(atan2(imag(r),real(r))*fs/(2*pi));
for i=1:length(ffreq)
fprintf('Formant %dFrequency%. 1f\n',i,ffreq(i));
end
figure;
plot(a);
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Interpolation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!