You are on page 1of 1

12/11/2017 Combine Clean Speach with Noise Code

CombineCleanSpeachwithNoiseCode

% Name Files
noiseFile = 'rainNoise.mp3'; % Change names for each kind of samples
outputNoise = 'rainNoiseReal.wav';
sn_noise = 'realWithRain.wav';

% Read Noise
[n,nfs] = audioread(noiseFile);
[s,sfs] = audioread('speechSample.mp3'); % Read clean Speach
%s = (s(:,1)+s(:,2));
n = (n(:,1)+n(:,2));

% Resample Noise Signal with Signal Sample Frequency


n = resample(n,sfs,nfs);

% Choose Noise Length to Make it as long as Signal


startSam = 1506;
n=n(startSam:startSam + length(s) - 1,1);

% Combine Signal with Noise and adjust the amplitude.


s_n = s + 0.25*n;

% Record the Noisy Signal


audiowrite(sn_noise,s_n,sfs);
audiowrite(outputNoise,n,sfs);

PublishedwithMATLABR2017a

le:///Users/Y/Desktop/Google%20%E4%BA%91%E7%AB%AF%E7%A1%AC%E7%9B%98/EECS%20351/EECS351%20Project/Final/Code_TO_SUBMIT_V3/h 1/2

You might also like