% m-file to take spectrogram of students' "open" and "give me' % voce_spc.m % 7/16/03 - fixed DC offset bug found by student % small change seen in training because DC offset was small % 2/23/97, G. Dempsey % Bradley University, Electrical & Computer Engineering clear % get time domain info for 6 students and build a matrix % truncate to shortest segment y7 ly7=2563; y1=wavread('h:\ee410\hw8\olee.wav'); % open for Lee y1=y1(1:ly7); P=y1; clear y1 y2=wavread('h:\ee410\hw8\glee.wav'); % give me for Lee y2=y2(1:ly7); P=[P y2]; clear y2 y3=wavread('h:\ee410\hw8\ojoel.wav'); y3=y3(1:ly7); P=[P y3]; clear y3 y4=wavread('h:\ee410\hw8\gjoel.wav'); y4=y4(1:ly7); P=[P y4]; clear y4 y5=wavread('h:\ee410\hw8\ojeff.wav'); y5=y5(1:ly7); P=[P y5]; clear y5 y6=wavread('h:\ee410\hw8\gjeff.wav'); y6=y6(1:ly7); P=[P y6]; clear y6 y7=wavread('h:\ee410\hw8\ocurtis.wav'); y7=y7(1:ly7); P=[P y7]; clear y7 y8=wavread('h:\ee410\hw8\gcurtis.wav'); y8=y8(1:ly7); P=[P y8]; clear y8 y9=wavread('h:\ee410\hw8\okurt.wav'); y9=y9(1:ly7); P=[P y9]; clear y9 y10=wavread('h:\ee410\hw8\gkurt.wav'); y10=y10(1:ly7); P=[P y10]; clear y10 y11=wavread('h:\ee410\hw8\obecky.wav'); y11=y11(1:ly7); P=[P y11]; clear y11 y12=wavread('h:\ee410\hw8\gbecky.wav'); y12=y12(1:ly7); P=[P y12]; clear y12 % South-East U.S. Test Voices y13=wavread('h:\ee410\hw8\ogary.wav'); y13=y13(1:ly7); P=[P y13]; clear y13 y14=wavread('h:\ee410\hw8\ggary.wav'); y14=y14(1:ly7); P=[P y14]; clear y14 y15=wavread('h:\ee410\hw8\odana.wav'); y15=y15(1:ly7); P=[P y15]; clear y15 y16=wavread('h:\ee410\hw8\gdana.wav'); y16=y16(1:ly7); P=[P y16]; clear y16 % eliminate DC content and normalize data for i=1:16 m=mean(P(:,i)); P(:,i)=P(:,i)-m; % remove DC P(:,i)=P(:,i)/max(abs(P(:,i))); % normalize end disp('Compute Spectrogram') % setup code for frequency response of input signals (fft) Npts=256; % 256 pt FFT to distinquish freuencies % freq div= 8KHz/256= 31.25 Hz [x1,f,t]=specgram(P(:,1),Npts,8000); % take spectrogram x2=specgram(P(:,2),Npts,8000); x3=specgram(P(:,3),Npts,8000); x4=specgram(P(:,4),Npts,8000); x5=specgram(P(:,5),Npts,8000); x6=specgram(P(:,6),Npts,8000); x7=specgram(P(:,7),Npts,8000); x8=specgram(P(:,8),Npts,8000); x9=specgram(P(:,9),Npts,8000); x10=specgram(P(:,10),Npts,8000); x11=specgram(P(:,11),Npts,8000); x12=specgram(P(:,12),Npts,8000); x13=specgram(P(:,13),Npts,8000); x14=specgram(P(:,14),Npts,8000); x15=specgram(P(:,15),Npts,8000); x16=specgram(P(:,16),Npts,8000); clear P x1=x1(1:48,:); % look at 0-1500Hz only % x1 is 48x19 matrix x2=x2(1:48,:); x3=x3(1:48,:); x4=x4(1:48,:); x5=x5(1:48,:); x6=x6(1:48,:); x7=x7(1:48,:); x8=x8(1:48,:); x9=x9(1:48,:); x10=x10(1:48,:); x11=x11(1:48,:); x12=x12(1:48,:); x13=x13(1:48,:); x14=x14(1:48,:); x15=x15(1:48,:); x16=x16(1:48,:); % create 1D matrix for ANN training count=1; disp('create 1D matrix for ANN') for i=1:48 for j=1:19 z1(count)=x1(i,j); z2(count)=x2(i,j); z3(count)=x3(i,j); z4(count)=x4(i,j); z5(count)=x5(i,j); z6(count)=x6(i,j); z7(count)=x7(i,j); z8(count)=x8(i,j); z9(count)=x9(i,j); z10(count)=x10(i,j); z11(count)=x11(i,j); z12(count)=x12(i,j); z13(count)=x13(i,j); z14(count)=x14(i,j); z15(count)=x15(i,j); z16(count)=x16(i,j); count=count+1; end end % free up memory clear x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 % build another Pattern matrix P=[z1' z2' z3' z4']; clear z1 z2 z3 z4 P=[P z5' z6' z7' z8']; clear z5 z6 z7 z8 P=[P z9' z10' z11' z12']; clear z9 z10 z11 z12 P=[P z13' z14' z15' z16']; clear z13 z14 z15 z16 % take absolute value and normalize data disp('normalize spectrogram data') for i=1:16 P(:,i)=abs(P(:,i)); m=max(P(:,i)); P(:,i)=P(:,i)/m; end