程序代码如下:
1.%短时谱函数
figure(1)
clear
a=wavread('speech_c.wav');
subplot(2,1,1)
plot(a);title('original signal');
grid
N=256;
h=hamming(N);
form=1:N
b(m)=a(m)*h(m)
end
y=20*log(abs(fft(b)))
subplot(2,1,2)
plot(y);title('短时谱');
grid
2.%语谱图
figure(2)
[x,fs,nbits]=wavread('speech_c.wav')
specgram(x,512,fs,100);
xlabel('时间(s)');
ylabel('频率(Hz)');
title('语谱图');
3.%短时能量
figure(3);
a=wavread('speech_c.wav');
sound(a);
subplot(6,1,1),plot(a);
N=32;
fori=2:6
h=linspace(1,1,2.^(i-2)*N); %形成一个矩形窗,长度为2.^(i-2)*N
En=conv(h,a.*a);% 求短时能量函数En
subplot(6,1,i),plot(En);
if(i==2) legend('N=32');
elseif(i==3) legend('N=64');
elseif(i==4) legend('N=128');
elseif(i==5) legend('N=256');
elseif(i==6) legend('N=512');
end
end
figure(4);
a=wavread('bird.wav');
subplot(6,1,1),plot(a);