data=getspeech('erf1s1t0.wav'); Nbits=5; nlevels=2^Nbits; Fs=12500; clg plot(data) end1=input('end1?'); end2=input('end2?'); datar=data(end1:end2); mind=min(datar); maxd=max(datar); amax=max(maxd,abs(mind)); range=maxd-mind; qdelta=range/nlevels; qdata=-amax+qdelta*round((datar+amax)/qdelta); qdata=qdata-mean(qdata); input('Utterance played back at orignal sampling rate, Fs = 12.5 KHz'); soundsc(datar,Fs); input('Utterance played backed with no. of bits equal to'); Nbits soundsc(qdata,Fs); subplot(211) plot(datar) title('orignal speech data with 12 bits per sample') subplot(212) plot(qdata) title('quanitized data with Nbits per sample') input('quantization error plotted next'); clg plot(datar-qdata) title('quantization error') dlength=end2-end1+1; axis([1 dlength mind maxd]) domega=2*pi/8192; omega=-pi:domega:pi-domega; daf1=abs(fftshift(fft(datar,8192))); input('DTFTs plotted next'); clg subplot(211) plot(omega,daf1) axis([-pi pi 0 max(daf1)]); title('Magnitude of DTFT of original utterance'); xlabel('omega (radians/s)'); subplot(212) qdaf=abs(fftshift(fft(qdata,8192))); plot(omega,qdaf) axis([-pi pi 0 max(qdaf)]); title('Magnitude of DTFT of quantized waveform'); xlabel('omega (radians/s)');