clear all; s = wavread('sentence.wav'); fs = 16000; %compression Rate for L = 0 : 4 b = L * 25; %b=input('Enter the Compression Rate Required\n'); % Choosing the Window Length l = length(s); s = s'; samples = ceil(l * (1+b/100)); diff = abs(samples - l); d = diff; if b > 0 for j = samples: -ceil(samples/d) : 5 for i = 1 : (ceil(samples/d)-1) sent(1,(j+1-i)) = s(1,(j+1-i-diff)); end sent(1,(j-i)) = sqrt((s(1,(j-(diff+1)-i))^2 + s(1,(j-(diff-1)-i))^2)/2); diff = diff -1; end elseif b < 0 ele = 0; for j = 1 : ceil(samples/d) : samples for i = 1 : ceil(samples/d) sent(1,(j+1-i)) = s(1,(j+1-i+ele)); end ele = ele + 1; end elseif b == 0 for i = 1 : samples sent(1,i) = s(1,i); end end % a=input('Enter the starting sample number\n'); % Choosing the speech segment a = 2500; s1=sent(a:a+3000); % Smoothing it with a window s2=conv(hamming(100),s1); % Finding the Average magnitude difference function for k=1:length(s2)-1 d(k)=0; for n=k+1:length(s2) d(k)=d(k)+(s2(n)-s2(n-k)); end end %figure(2); %plot(d); %title('The AMDF function plot for the chosen speech segment'); %xlabel('Samples'); j=1; % Finding the minimum points to calculate the pitch for i=1:length(d)/2 if d(i+1)