%endpointdetection.m
function[res1,res2,speechsegment,utforste,ltforste,ltforzcr]=endpointdetection1(S,FS)
%->F1 270 to 730 F2-840 to 2290 F3-1690 to 3010 Hz
%160 HZ 200 Hz and 300 Hz
SEGLEN=FS*30*10^(-3);
S=speechsegment;
S1=S(fix(length(S)/2):SEGLEN-1+fix(length(S)/2));
S1=S1.*hamming(length(S1))';
subplot(2,2,1)
plot(S1)
L=lpc(S1,11);
[H,W]=freqz(1,L);
subplot(2,2,3)
plot(abs(H))
H=abs(H)/max(abs(H));
R=roots(L);
subplot(2,2,4)
zplane(R)
P=[];
for i=1:1:11
P=[P phase(R(i))];
end
[T]=find(P>=0);
POSP=P(T);
th1=round((1024*80)/FS);
th2=round((1024*100)/FS);
th3=round((1024*150)/FS);
F1=Forcollect(H,W,POSP,th1,FS);
F2=Forcollect(H,W,POSP,th2,FS);
F3=Forcollect(H,W,POSP,th3,FS);
F=[F1 F2 F3];
F=remdup(F);