【发布时间】:2017-08-01 09:45:01
【问题描述】:
虽然可能有可用的内置函数,但我需要创建自己的三角滤波器组。下面是我的代码。我在我的 HMatrix (filterbank) 中得到 NaN 值。这是由于创建矩阵时使用的 FreqArray 中的“相同”值。我在以下问题上需要帮助:
- 知道我选择的44100Hz的采样频率是否正确?
- 如何选择低频=300Hz和高频=8000Hz来计算梅尔滤波器组矩阵?
- 如何选择合适的帧大小(frame_length)和梅尔滤波器数量(no_of_coeffs)?
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
代码基于以下等式:
以上代码输出的主要部分如下所示,以供参考。
作为参考,我使用了以下网站:
提前致谢!
【问题讨论】:
标签: matlab speech-recognition mfcc filter-bank