|
我附上degrade函数:
% [Y] = degrade(X,SNR,NOISE)
% adds SNR dB NOISE to the speech signal X and returns the noisy signal in Y
% By default SNR=10dB and NOISE is AWGN.
function [Y] = degrade(X,SNR,NOISE)
if isstr(X)==1, X=read(X); end
if nargin < 3, NOISE=randn(size(X)); end
if nargin < 2, SNR=10; end
if length(NOISE) < length(X),
disp('Length of speech signal X should be greater than noise NOISE');
break
end
signal_power = 1/length(X)*sum(X.*X);
noise_variance = signal_power / ( 10^(SNR/10) );
Y=X+sqrt(noise_variance)/std(NOISE)*NOISE(1:length(X));
Y=32000/max(abs(Y))*Y; |
|