[Speech denoising] Based on matlab LMS spectrum subtraction voice denoising [Include Matlab source code 529]

1. Introduction

Least Mean Squares (LMS, Least Mean Squares) is the most basic adaptive filtering algorithm.
The LMS algorithm is a commonly used algorithm in adaptive filters. The difference from the Wiener algorithm is that the coefficients of the system change with the input sequence. In the Wiener algorithm, a section of the autocorrelation function of the input sequence is intercepted to construct the optimal coefficient of the system. The LMS algorithm is implemented by continuously correcting the initialized filter coefficients according to the minimum mean square error criterion. Therefore, theoretically speaking, the performance of the LMS algorithm is better than Wiener under the same conditions. However, the LMS is adjusted gradually under the initial value, so before the system is stable, there will be a period of adjustment time. The adjustment time is controlled by the step size factor. Within a certain range, the larger the step size factor, the smaller the adjustment time, and the step size factor The maximum value of is the trace of R. LMS adopts the principle of minimum square error instead of the principle of minimum mean square error, and the basic signal relationship is as follows:
Insert picture description here
Insert picture description here

Second, the source code

clear all;clc; close  all;
%filedir=[D:\Program Files\MATLAB\speech.wav];  %路径设置不对,以下用不到就省略掉,直接用下行代码的文件名
filename='speech.wav';  
%fle=[filedir filename];       %无用行,以下没用到
[s,fs] =audioread(filename);   %wavread函数在此版本后不能用了,改用audioread
s=s/max(abs(s));     %将语音信号幅值归一化
N=length(s);         %求信号的长度
time=(0:N-1)/fs;     %设置横坐标的时间
ns=0.5*cos(2* pi* 50* time);   %计算出50Hz的工频信号
x=s+ns';      %语音信号和50Hz的工频信号叠加
snr1=SNR_singlech(s,x);     %计算叠加后50Hz工频信号之后的信噪比
x1=cos(2* pi * 50 * time);  %设置x1和x2
x2=cos(2* pi * 50 * time);
w1=0.1;        %初始化w1和w2
w2=0.1;
e=zeros(1,N);  %初始化e和y
y=zeros(1,N);
mu=0.05;       %设置mu
for i=1:N 
    y(i)=w1* x1(i)+ w2* x2(i);   %LMS自适应陷波器滤波
    e(i)=x(i)-y(i);
    w1=w1+mu* e(i) * x1(i);
    w2=w2+mu* e(i) * x2(i);
end
output=e';    %陷波器输出
snr2=SNR_singlech(s,output);     %计算滤波后的输出
snr=snr2-snr1;
fprintf('snr1=%5.4f  snr2=%5.4f  snr=%5.4f\n',snr1,snr2,snr);
%wavpaly(x,fs);        %从声卡发声比较
audioplayer(x,fs)
pause(1);
audioplayer(output,fs);
wavwrite(output,'hehe.wav');

Three, running results

Insert picture description here

Four, remarks

Complete code or writing add QQ 1564658423 past review
>>>>>>
[Feature extraction] Audio watermark embedding and extraction based on matlab wavelet transform [Include Matlab source code 053]
[Speech processing] Voice signal processing based on matlab GUI [Include Matlab Source code issue 290]
[Voice acquisition] based on matlab GUI voice signal collection [including Matlab source code 291]
[Voice modulation] based on matlab GUI voice amplitude modulation [including Matlab source code 292]
[Speech synthesis] based on matlab GUI voice synthesis [including Matlab Source code issue 293]
[Voice encryption] Voice signal encryption and decryption based on matlab GUI [With Matlab source code 295]
[Speech enhancement] Matlab wavelet transform-based voice enhancement [Matlab source code 296]
[Voice recognition] Based on matlab GUI voice base frequency Recognition [Including Matlab source code 294]
[Speech enhancement] Matlab GUI Wiener filtering based voice enhancement [Including Matlab source code 298]
[Speech processing] Based on matlab GUI voice signal processing [Including Matlab source code 299]
[Signal processing] Based on Matlab speech signal spectrum analyzer [including Matlab source code 325]
[Modulation signal] Digital modulation signal simulation based on matlab GUI [including Matlab source code 336]
[Emotion recognition] Voice emotion recognition based on matlab BP neural network [including Matlab source code 349 Issue]
[Voice Steganography] Quantified Audio Digital Watermarking Based on Matlab Wavelet Transform [Include Matlab Source Code Issue 351]
[Feature extraction] based on matlab audio watermark embedding and extraction [including Matlab source code 350 period]
[speech denoising] based on matlab low pass and adaptive filter denoising [including Matlab source code 352 period]
[emotion recognition] based on matlab GUI voice emotion classification Recognition [Including Matlab source code 354 period]
[Basic processing] Matlab-based speech signal preprocessing [Including Matlab source code 364 period]
[Speech recognition] Matlab Fourier transform 0-9 digital speech recognition [Including Matlab source code 384 period]
[Speech Recognition] 0-9 digital speech recognition based on matlab GUI DTW [including Matlab source code 385]
[Voice playback] Matlab GUI MP3 design [including Matlab source code 425]
[Voice processing] Speech enhancement algorithm based on human ear masking effect Noise ratio calculation [Including Matlab source code 428]
[Speech denoising] Based on matlab spectral subtraction denoising [Including Matlab source code 429]
[Speech recognition] BP neural network speech recognition based on the momentum item of matlab [Including Matlab source code 430]
[Voice steganography] based on matlab LSB voice hiding [including Matlab source code 431]
[Voice recognition] based on matlab male and female voice recognition [including Matlab source code 452]
[Voice processing] based on matlab voice noise adding and noise reduction processing [including Matlab source code Issue 473]
[Speech denoising] based on matlab least squares (LMS) adaptive filter [including Matlab source code 481]
[Speech enhancement] based on matlab spectral subtraction, least mean square and Wiener filter speech enhancement [including Matlab source code 482 period】
[Communication] based on matlab GUI digital frequency band (ASK, PSK, QAM) modulation simulation [including Matlab source code 483]
[Signal processing] based on matlab ECG signal processing [including Matlab source code 484]
[Voice broadcast] based on matlab voice Broadcast [Including Matlab source code 507]
[Signal processing] Matlab wavelet transform based on EEG signal feature extraction [Including Matlab source code 511]
[Voice processing] Based on matlab GUI dual tone multi-frequency (DTMF) signal detection [Including Matlab source code 512 】
【Voice steganography】based on matlab LSB to realize the digital watermark of speech signal 【Include Matlab source code 513】
【Speech enhancement】Speech recognition based on matlab matched filter 【Include Matlab source code 514】
【Speech processing】Based on matlab GUI voice Frequency domain spectrogram analysis [including Matlab source code 527]
[Speech denoising] based on matlab LMS, RLS algorithm voice denoising [including Matlab source code 528]
[Voice denoising] based on matlab LMS spectral subtraction voice denoising [including Matlab Source code issue 529]
[Voice denoising] based on matlab soft threshold, hard threshold, compromise threshold voice denoising [including Matlab source code 530]
[Voice recognition] based on matlab specific person's voice recognition discrimination [including Matlab source code 534]
[ Speech denoising] based on matlab wavelet soft threshold speech denoising [including Matlab source code 531]

Guess you like

Origin blog.csdn.net/TIQCmatlab/article/details/114871082