簡體   English   中英

如何創建在MFCC中用於MATLAB中語音識別的三角形(Mel)濾鏡庫?

[英]How to create a Triangular (Mel) Filter Bank used in MFCC for speech recognition in MATLAB?

盡管可能有內置的功能可用,但我需要創建自己的三角濾波器組。 下面是我的代碼。 我在HMatrix(filterbank)中得到NaN值。 這是由於創建矩陣時使用的FreqArray中的“相同”值所致。 我在以下問題上需要幫助:

  1. 知道我選擇的44100Hz采樣頻率是否正確嗎?
  2. 如何選擇較低的頻率= 300Hz和較高的頻率= 8000Hz來計算梅爾濾波器組矩陣?
  3. 如何選擇合適的幀大小(frame_length)和梅爾濾波器的數量(no_of_coeffs)?

function TriFilterBank()
tic
%-----------------------------INITIALISATION---------------------------%

fs=44100; %frequency at which I have sampled my recorded samples frame_length=256; %How to choose an appropriate frame-size? low_freq=300; %lower frequency for calculation of mel frequency filter bank (I'm unable to choose a correct one, and find the criteria for choosing it) high_freq=8000; %upper frequency for calculation of mel frequency filter bank (I'm unable to choose a correct one, and find the criteria for choosing it) % I have also tried with (fs/2)=22050Hz, but nno good results no_of_coeffs=20; % This is no. of Mel-Filter banks to create. how to choose a approriate value for this for speech processing applications? %--------------------------------------------------PRE-PROCESSING FOR MEL FILTER BANK CREATION-----------------------------------------------% low_linear=2595*log10(1+(low_freq/700)); high_linear=2595*log10(1+(high_freq/700)); band_length=(high_linear-low_linear)/(no_of_coeffs+1); MelArray(no_of_coeffs+2,1)=zeros(); %to store mel frequencies to calculate mel frequency filter bank LinearArray(no_of_coeffs+2,1)=zeros(); %to store linear frequencies to calculate mel frequency filter bank FreqArray(no_of_coeffs+2,1)=zeros(); %to store frequency array to calculate mel frequency filter bank %{ THIS ARRAY MAY HAVE WRONG VALUES DUE TO SELECTION of WRONG PARAMETERS LIKE low_freq, high_freq, frame_length (frame-size), no_of_coeffs (no. of filter banks). THIS IS MAJOR REASON BEHIND GENERATION OF NaN values in HMatrix %} HMatrix(no_of_coeffs,frame_length)=zeros(); %Hmk Matrix/ Filter Bank I'M VERY DOUBTFUL OF THE VALUES GENERATED BY THIS FILTER BANK MelArray(1)=low_linear; MelArray(no_of_coeffs+2)=high_linear; LinearArray(1)=low_freq; LinearArray(no_of_coeffs+2)=high_freq; FreqArray(1)=floor((int32(frame_length)+1)*LinearArray(1)/fs); FreqArray(no_of_coeffs+2)=floor((int32(frame_length)+1)*LinearArray(no_of_coeffs+2)/fs); for m=1:no_of_coeffs MelArray(m+1)=MelArray(m)+band_length; LinearArray(m+1)=700*((power( 10,MelArray(m+1)/2595))-1); FreqArray(m+1)=floor((int32(frame_length)+1)*LinearArray(m+1)/fs); %The values generated here seem to be doubtful, hence maybe an incorrect filter bank end % THE MOST DOUBTFUL/WRONG PART i.e. MEL FREQUENCY FILTER BANK MATRIX CREATION %---------------------------------------------------------PROBABLE ERRONEOUS PART------------------------------------------------------------% % I'M GETTING NaN values in this matrix probably due to choosing incorrect parameters for like upper freq, lower freq, frame-size, no.of filter banks, sampling frequency etc. % In FreqArray I'm getting two same values, hence it's satisfying none of the below conditions and generating a NaN value. for k=1:frame_length for m=1:no_of_coeffs if(k<FreqArray(m)) HMatrix(m,k)=0; elseif (FreqArray(m)<=k && k<=FreqArray(m+1)) HMatrix(m,k)=(k-FreqArray(m))/(FreqArray(m+1)-FreqArray(m)); elseif(FreqArray(m+1)<=k && k<=FreqArray(m+2)) HMatrix(m,k)=(FreqArray(m+2)-k)/(FreqArray(m+2)-FreqArray(m+1)); elseif (k>FreqArray(m+2)) HMatrix(m,k)=0; end end end %--------------------------------------------------------------------------------------------------------------------------------------------% save('TriFilterBank'); toc end

該代碼基於以下等式:

梅爾濾波器組方程

上面的代碼輸出的主要部分如下所示,以供參考。

HMatrix(FilterBank)-圖片1

HMatrix(FilterBank)-圖片2

HMatrix(FilterBank)-圖片3

線性數組

MelArray

頻率陣列

作為參考,我使用了以下網站:

http://practicalcryptography.com/miscellaneous/machine-learning/guide-mel-frequency-cepstral-coefficients-mfccs/

提前致謝!

知道我選擇的44100Hz采樣頻率是否正確嗎?

這個頻率很好。 無論如何,語音駐留在16khz以下,因此16kHz是更常見的選擇。 在您用作參考的博客文章中,它是16kHz。

如何選擇較低的頻率= 300Hz和較高的頻率= 8000Hz來計算梅爾濾波器組矩陣?

此范圍不是最佳范圍,但對於大多數應用程序來說還可以。 為了獲得高質量的聲音,范圍為20Hz至7600Hz。

如何選擇合適的幀大小(frame_length)和梅爾濾波器的數量(no_of_coeffs)?

語音的幀大小通常約為25毫秒,這是在一幀內提供平穩性和正常速率語音分辨率的最佳值。 對於44100 kHz的采樣率,它以幀中的大約1128(44100 * 0.025)個元素結束,而不是您選擇的256個元素。 如果要具有2的冪,則一幀中需要2048個元素。 這也將是FFT階數。

梅爾過濾器的數量可以是15-40,在許多系統中使用20是一個很好的值,發現它在實驗中很有用。

最好閱讀現有的實現,有許多您從本教程中學不到的東西,其中一個很好的是VoiceBox

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM