%Katelyn Nye, EEN 540 - Spring 2008: Project 1 % Wave Read in word_name = input('What is the word you would like to evaluate? ','s'); word_wave_name = strcat('katelyn_',word_name,'.wav'); [x,Fs,bits] = wavread(word_wave_name); phoneme_name = input('What is the phoneme? ','s'); phoneme_start = input('When does the phoneme begin? '); phoneme_end = input('When does the phoneme end? '); phoneme_length = phoneme_end-phoneme_start; %Time Waveform of Word t=[0:1/Fs:(length(x)-1)/Fs]; figure(1) subplot(3,1,1) plot(t,x) title({'Time Waveform of the Word: ';word_name}) xlabel('Time (s)') ylabel('Amplitude') %Time Waveform of Phoneme figure(2) subplot(3,1,1) plot(t,x) xlim([phoneme_start phoneme_end]) title({'Time Waveform of Phoneme: ';phoneme_name}) xlabel('Time (s)') ylabel('Amplitude') % Narrowband Spectrogram plot N=512; HannWindow_narrow=hanning(N); figure(1) subplot(3,1,2) [s_n,F_n,t_n]=SPECGRAM(x,N,Fs,HannWindow_narrow,round(.97*N)); SPECGRAM(x,N,Fs,HannWindow_narrow,round(.97*N)) title('Narrowband Spectrogram Plot') % Wideband Spectrogram plot N=512; HannWindow_wide=hanning(N/4); figure(1) subplot(3,1,3) [s_w,F_w,t_w]=SPECGRAM(x,N,Fs,HannWindow_wide,round(.9*N/4)); SPECGRAM(x,N,Fs,HannWindow_wide,round(.9*N/4)) title('Wideband Spectrogram Plot') pic1=strcat('katelyn_',word_name,'_pic1'); A = figure(1); saveas(A, pic1, 'jpg'); %25 ms of unvoiced speech voiced_phoneme = input('Is the phoneme voiced? (y for yes, n for no) ','s'); if voiced_phoneme=='n' unvoiced_start = input('Where do you want to begin a 25 ms section? '); figure(2) subplot(3,1,2) plot(t,x) xlim([(unvoiced_start) (unvoiced_start+.025)]) title('Time Waveform of 25 ms of the Unvoiced Phoneme') xlabel('Time (s)') ylabel('Amplitude') p_part=x(unvoiced_start*Fs:(unvoiced_start+.025)*Fs); end %3 voiced periods if voiced_phoneme=='y' period_start = input('When do three periods of the phonemes begin? '); period_end = input('When do the three periods of the phoneme end? '); figure(2) subplot(3,1,2) plot(t,x) xlim([(period_start) (period_end)]) title('Time Waveform of Three Periods of Voiced Phoneme') xlabel('Time (s)') ylabel('Amplitude') p_part=x((period_start)*Fs:(period_end)*Fs); end %Magnitude Spectrum and Linear Prediction Spectral Envelope mag=abs(fft(p_part,1024)); mag=mag(1:512); freq=0:8000/N:8000-1; figure(2) subplot(3,1,3) plot(freq, db(mag/1024)); % divide by 512 to normalize after fourier transform axis tight; grid on; title('Magnitude Spectrum and Smoothed Spectral Envelope'); xlabel('Frequency (Hz)'); ylabel('|X(f)| (dB)'); hold on %Smoothing - Linear Prediction p=Fs/1000 + 4; [a,g]=lpc(p_part,p); lspec=freqz(g,a, freq, Fs); subplot(3,1,3) plot(freq, db(abs(lspec)), 'r'); axis tight; title('Magnitude Spectrum in Blue & Smoothed Spectral Envelope in Red'); pic2=strcat('katelyn_',word_name,'_pic2'); B = figure(2); saveas(B, pic2, 'jpg');