clc;
clear all;
close all;
[A,FS]=audioread('D:\GOPI\DIGITAL_SPEECH_PROCESSING_USING_MATLAB\data\train\s4.wav');
S=A';
%function [pitchfrequency]=pitchestautocorr(S,FS)
[res1,res2,speechsegment,utforste,ltforste,ltforzcr]=endpointdetection(S,FS)
SEGLEN=FS*30*10^(-3);
S=speechsegment;
S1=S(fix(length(S)/2):SEGLEN-1+fix(length(S)/2));
T=[];
HIGH=fix(FS/85);
LOW=fix(FS/255);
 for k=LOW:1:HIGH
     T=[T  sum([zeros(1,k) S1 ].*[S1 zeros(1,k) ])];
 end
 [P,Q]=max(T);
 pitchperiod=Q+LOW;
 pitchfrequency=FS/pitchperiod;
 
 
 
 
 
 