matlab给语音信号添加噪声

我们有时会做算法分析,我们需要在信号中添加噪声来验证我们算法的健壮性。

[En]

We sometimes do algorithm analysis, we need to add noise to the signal to verify the robustness of our algorithm.

以语音信号为例,将指定信噪比加到信号上的高斯白噪声程序如下:

[En]

Taking the speech signal as an example, the Gaussian white noise program for adding a specified signal-to-noise ratio to the signal is as follows:

data=xx(10000:26000); %读入数据

%添加噪声
snr = 10; %设定信噪比,单位db

%输出参数data是带噪语音,noise为加在信号上的白噪声
[data,noise] = Gnoisegen(data,snr);

添加噪声的函数Gnoisegen:

function [y,noise] = Gnoisegen(x,snr)

noise=randn(size(x));              % 用randn函数产生高斯白噪声

Nx=length(x);                      % 求出信号x长

signal_power = 1/Nx*sum(x.*x);     % 求出信号的平均能量

noise_power=1/Nx*sum(noise.*noise);% 求出噪声的能量

noise_variance = signal_power / ( 10^(snr/10) );    % 计算出噪声设定的方差值

noise=sqrt(noise_variance/noise_power)*noise;       % 按噪声的平均能量构成相应的白噪声

y=x+noise;                         % 合成带噪语音

Original: https://blog.csdn.net/qq_38699252/article/details/109848350
Author: GodenEngineer
Title: matlab给语音信号添加噪声

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/524974/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球