clear all; s = wavread('sentence.wav'); fs = 16000; % EXPANSION RATE b=input('Enter the Required Percentage of Speed Increase\n'); % CHOOSING THE WINDOW LENGTH winLen = 30 * 16; l = length(s); s = s'; % DETERMINING THE NO.OF SAMPLES TO BE SHIFTED shiftSamples = winLen*(b/2) / 100; %LENGTH OF THE FINAL SENTENCE e= ceil(l*(1+b/100))+ ceil(l/winLen)+100000; s3 = zeros(1,e); j1 = ceil(2*winLen/3); tic for a = 1 : ceil(winLen/3) : (length(s)-winLen) %To Find The Optimum Shift for i = 1 : winLen Ms(i) = s(i+a-1); end if (shiftSamples+40 > winLen) temp = winLen; else temp = shiftSamples+40; end if (shiftSamples-40 < 0) temp1 = 1; else temp1 = shiftSamples-40; end n=0; for j = temp1 : temp n = n + 1; MSE(n) = 0; for i = j+1 : winLen MSE(n) = MSE(n) + (Ms(i) - Ms((i-j)))^2; end MSE(n) = MSE(n)/(winLen - j+1); end [Y,I] = min(MSE); optShift = shiftSamples - (ceil(n/2) - I); % TIME SHIFTING AND ADDING A WINDOW ONTO ITSELF s1 = zeros(1,(winLen+optShift)); for i = 1 : winLen s1(i) = s(i+a-1); end for i = 1 : (optShift+winLen) if i <= optShift s2(i) = s1(i); else s2(i) = s1(i) + s1(i-optShift); end end %CREATING THE FINAL SENTENCE j1 = j1 - ceil(2*winLen/3); for i = 1 : (winLen+optShift) j1=j1+1; s3(j1) = s3(j1) + s2(i); end end j1 t=toc figure(1); subplot(2,1,2); plot(s); subplot(2,1,2); plot(s3);