1.软件版本
matlab2021a
2.本算法理论知识
处理宽带噪声的最通用技术是谱减法,即从带噪语音估值中减去噪声频谱估值,而得到纯净语音的频谱。由于人耳对语音频谱分量的相位不敏感,因而这种方法主要针对短时幅度谱。假定语音为平稳信号,而噪声和语音为加性信号且彼此不相关。此时带噪语音信号可表示为。
3.部分核心代码
function enhancedsignal=wiener(noisyspeech,samplefrequency)
x=noisyspeech;
fs=samplefrequency;
nx=length(x);
enhanced_x=zeros(1,nx);
%分帧和加窗
FrameLen=fix(0.025*fs); %取25毫秒为一帧
overlap=FrameLen/2;
inc=FrameLen-overlap; %帧移
x_frame=enframe(x,FrameLen,inc); %分帧
nf=size(x_frame,1); % 帧数
win=hamming(FrameLen)';
x_window=[];
for k=1:nf
x_row=x_frame(k,:).*win; % 加窗
x_window=[x_window;x_row];
end
%对带噪语音进行DFT
y=fft(x_window');
ymag = abs(y);
yphase = angle(y);
NNoise=23; %取噪音段(语音的初始段)帧数
MN=mean(ymag(:,1:NNoise)')';
PN=mean(ymag(:,1:NNoise)'.^2)'; %初始噪声功率谱均值
NoiseCounter=0;%连续噪声段长度
SmoothFactor=9;%噪声平滑因子
Alpha=0.95; %语音平滑因子
SNRPre=ones(size(MN));
%维纳滤波
for k=1:nf
if k<=NNoise
SpeechFlag=0;
NoiseCounter=NNoise;
else
NoiseMargin=3;
HangOver=8;
SpectralDist= 20*(log10(ymag(:,k))-log10(MN));
SpectralDist(find(SpectralDist<0))=0;
Dist=mean(SpectralDist);
if (Dist < NoiseMargin)
NoiseFlag=1;
NoiseCounter=NoiseCounter+1;
else
NoiseFlag=0;
NoiseCounter=0;
end
if (NoiseCounter > HangOver)
SpeechFlag=0;
else
SpeechFlag=1;
end
end
if SpeechFlag==0
MN=(SmoothFactor*MN+ymag(:,k))/(SmoothFactor+1); %更新噪声均值
PN=(SmoothFactor*PN+(ymag(:,k).^2))/(1+SmoothFactor); %更新噪声功率
end
%------滤波
SNRNew=(ymag(:,k).^2)./PN-1;
SNRPost=Alpha*SNRPre+(1-Alpha).*max(SNRNew,0);
Gain=SNRPost./(SNRPost+1);
smag=Gain.*ymag(:,k);
SNRPre=smag.^2./PN;
spectrum= smag.*exp(j*yphase(:,k));
enhanced_x((inc*(k-1)+1):(inc*(k-1)+FrameLen))=enhanced_x((inc*(k-1)+1):(inc*(k-1)+FrameLen))+real(ifft(spectrum,FrameLen))';
end
enhancedsignal=enhanced_x;
4.仿真结论
5.参考文献
[1] 易克初. 语音信号处理[M]. 北京:国防工业出版社, 2000.
[2] LiZhao, KOBAYASHI, NIIMI Y Tone. Recongnition of Chinese continuous speech using continuous HMMs[J]. Journal of the Acoustical Society of Japan, 53(12), 933-940, 1997.
A03-03
6.完整源码获得方式
方式1:微信或者QQ联系博主
方式2:订阅,免费获得教程案例代码以及本博任意2份完整源码