[y1,fs,nbits] = wavread('D:/data/sp01.wav'); //语音文件自己修改
figure(1);
specgram(y1,256,8000,256,128);
title('sp01');
x = y1;
nfft = 256;
Fs = 8000;
Window =window(256);
Noverlap = 128;
nx = length(x);
nwind = length(window);
x = x(:); % make a column vector for ease later
window = window(:); % be consistent with data set
ncol = fix((nx-noverlap)/(nwind-noverlap));
colindex = 1 + (0:(ncol-1))*(nwind-noverlap);
rowindex = (1:nwind)';
evenly_spaced = 1;
use_chirp = 0;
if (length(nfft)==1) | use_chirp
y = zeros(nwind,ncol);
% put x into columns of y with the proper offset
% should be able to do this with fancy indexing!
y(:) = x(rowindex(:,ones(1,ncol))+colindex(ones(nwind,1),:)-1);
% Apply the window to the array of offset signal segments.
y = window(:,ones(1,ncol)).*y;
if ~use_chirp % USE FFT
% now fft y which does the columns
y = fft(y,nfft);
if ~any(any(imag(x))) % x purely real
if rem(nfft,2), % nfft odd
select = 1:(nfft+1)/2;
else
select = 1:nfft/2+1;
end
y = y(select,:);
else
select = 1:nfft;
end
f = (select - 1)'*Fs/nfft;
end
end
t = (colindex-1)'/Fs;
% take abs, and use image to display results
t = ((colindex-1)+((nwind-noverlap)/2)')/Fs; % Shift time vector by half window length.
imagesc(t,f,20*log10(abs(y)+eps));axis xy; colormap(jet)
把和时序相关的傅里叶分析的显示图形称为语谱图(sonogram或者spectrogram).语谱图是一种三维频谱,它是表示语音频谱随时间变化的图形,其纵轴为频率,横轴为时间,任一给定频率成分在给定时刻的强弱用相应点的灰度或色调的浓淡来表示。用语谱图分析语音又称为语谱分析。语谱图中显示了大量的与语音的语句特性有关的信息,它综合了频谱图和时域波形的特点,明显地显示出语音频谱随时间的变化情况,或者说是一种动态的频谱。可以用语谱仪来记录这种谱图。
对于一段语音信号x(t),首先分帧,变为x(m,n)(n为帧长,m为帧的个数),做FFT变换,
得到X(m,n),做周期图Y(m,n)(Y(m,n) = X(m,n) * X(m,n)’),然后取10 *log10(Y(m,n)),把m根据时间变换一下刻度M,n根据频率变化一下刻度N,就(M,N, 10 *log10(Y(m,n) 画成二维图就是语谱图了。如果画成三维图。
mesh(t,f,20*log10(abs(y)+eps));
imagesc(t,f,20*log10(abs(y)+eps));
功率谱密度(power spectral density,PSD),
功率谱(power spectrum)
频谱(spectrum),包括两部分,幅度频谱(magnitude spectrum)和相位频谱(phase spectrum)
X=fft(x,nFFT);
Pxx=abs(X).^2/length(n);%求解PSD; //功率谱
Px = pxx/ fs,*fft //PSD
Magni_spectrum = abs(X);
Phase_spectrum = argtg(b/a);
求该信号的自相关函数的傅立叶变换 是一种方法。
采周期谱法,也就是做FFT,取模,平方,除以数据长度。
版主提供的方法是求功率谱。而功率谱密度是把功率谱除以fs,它的含义是每赫兹的功率。