资源简介
这是一个基于维纳后滤波算法的单声道语音增强程序,可以在MATLAB里面运行,很好用的
代码片段和文件信息
function wiener_as(filenameoutfile)
%
% Implements the Wiener filtering algorithm based on a priori SNR estimation [1].
%
% Usage: wiener_as(noisyFile outputFile)
%
% infile - noisy speech file in .wav format
% outputFile - enhanced output file in .wav format
%
% Example call: wiener_as(‘sp04_babble_sn10.wav‘‘out_wien_as.wav‘);
%
% References:
% [1] Scalart P. and Filho J. (1996). Speech enhancement based on a priori
% signal to noise estimation. Proc. IEEE Int. Conf. Acoust. Speech Signal
% Processing 629-632.
%
% Authors: Yi Hu and Philipos C. Loizou
%
% Copyright (c) 2006 by Philipos C. Loizou
% $Revision: 0.0 $ $Date: 10/09/2006 $
%-------------------------------------------------------------------------
if nargin<2
fprintf(‘Usage: wiener_as(noisyfile.wavoutFile.wav) \n\n‘);
return;
end
[noisy_speech fs nbits]= wavread( filename);
noisy_speech= noisy_speech;
% column vector noisy_speech
% set parameter values
mu= 0.98; % smoothing factor in noise spectrum update
a_dd= 0.98; % smoothing factor in priori update
eta= 0.15; % VAD threshold
frame_dur= 20; % frame duration
L= frame_dur* fs/ 1000; % L is frame length (160 for 8k sampling rate)
hamming_win= hamming( L); % hamming window
U= ( hamming_win‘* hamming_win)/ L; % normalization factor
% first 120 ms is noise only
len_120ms= fs/ 1000* 120; %%%120ms时间长度内的样点值
% first_120ms= noisy_speech( 1: len_120ms).* ...
% (hann( len_120ms ‘periodic‘))‘;
first_120ms= noisy_speech( 1: len_120ms);
% =============now use Welch‘s method to estimate power spectrum with
% Hamming window and 50% overlap
nsubframes= floor( len_120ms/ (L/ 2))- 1; % 50% overlap
noise_ps= zeros( L 1);
n_start= 1;
for j= 1: nsubframes
noise= first_120ms( n_start: n_start+ L- 1);
noise= noise.* hamming_
评论
共有 条评论