Site hosted by Angelfire.com: Build your free website today!

Matlab Code

% Read in the sound files

[word, fs] = wavread('at.wav'); [phoneme, fs] = wavread('@.wav');

%time domain plot

figure(1) subplot(4,1,1) t=0:1/fs:(length(word)-1)/fs; plot(t,word); title('Time Waveform'); ylabel('X(t)'); xlabel('Time,s'); grid on;

% Wideband Spectrogram

n=320; %window size

figure(1); subplot(4,1,2); specgram(word,n,fs,hamming(n),round(.97*n)); axis tight; title('Wideband Spectrogram');

%Narrowband Spectrogram

figure(1); subplot(4,1,3); N=320; specgram(word,n,fs,hamming(N/4),round(.90*n/4)); axis tight; title('Narrowband Spectrogram');

%Plot phoneme in time

t=0:1/fs:(length(phoneme)-1)/fs; figure(1) subplot(4,2,7); plot(t,phoneme); title('Phoneme Waveform'); xlabel('Time,s'); ylabel('x(t)'); grid on;

%Phoneme magnitude in frequency domain

y= fft(phoneme, 512); y=abs(y(1:512/2)); f=0:fs/512:fs/2-fs/512; f=f';

%Spectral envelope

p= fs/1000 + 4; hold on; [a,g]=lpc(phoneme,p); lspec=freqz(g,a, f, fs); subplot(4,2,8) plot(f, 20*log10(abs(lspec)), 'k');hold on; plot(f,20*log10(y/512)); axis tight; grid on; title('Magnitude Spectrum & Spectral Envelope'); xlabel('Frequency (Hz)'); ylabel('Mag (dB)');