語譜圖

[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根據時間變換一下刻度Mn根據頻率變化一下刻度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,它的含義是每赫茲的功率。

發佈了39 篇原創文章 · 獲贊 11 · 訪問量 10萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章