Formant Estimation With LPC Coefficients

7 views (last 30 days)
ldsk2234
ldsk2234 on 23 Jul 2020
I want to make it so I can read my own sound file (instead of loading the speech sample 'load mtlb') and produce the same output of 3 formant values. However, each time I try to do this I get the exact same formants as listed on the page below. Could someone please tell me what I am doing wrong.
[y1,Fs]=audioread('mysound.wav');
segmentlen = 100;
noverlap = 90;
NFFT = 128;
%spectrogram(mtlb,segmentlen,noverlap,NFFT,Fs,'yaxis')
spectrogram(y1,segmentlen,noverlap,NFFT,Fs,'yaxis')
title('Signal Spectrogram')
dt = 1/Fs;
I0 = round(0.1/dt);
Iend = round(0.25/dt);
x = y1(I0:Iend);
%%
x1 = x.*hamming(length(x));
preemph = [1 0.63];
x1 = filter(1,preemph,x1);
A = lpc(x1,8);
rts = roots(A);
rts = rts(imag(rts)>=0);
angz = atan2(imag(rts),real(rts));
[frqs,indices] = sort(angz.*(Fs/(2*pi)));
bw = -1/2*(Fs/(2*pi))*log(abs(rts(indices)));
nn = 1;
for kk = 1:length(frqs)
if (frqs(kk) > 90 && bw(kk) <400)
formants(nn) = frqs(kk);
nn = nn+1;
end
end
formants

Answers (0)

Community Treasure Hunt

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

Start Hunting!