Skip to content

Instantly share code, notes, and snippets.

@jameslyons
Last active August 29, 2015 14:10
Show Gist options
  • Save jameslyons/e146d9178d9e7e1fe3a3 to your computer and use it in GitHub Desktop.
Save jameslyons/e146d9178d9e7e1fe3a3 to your computer and use it in GitHub Desktop.
add_noise_to_NIST_files.m
SNR=40; % the SNR of white noise to apply to each file
path = '/home/james/databases/speech_db/timit_xxl_white/db/timit_full';
[status,result]=system(['find ',path,' -name "*.wav" | grep -v snr > ',path,'/timit_list.txt']);
listfilename = [path,'/timit_list.txt'];
filelist = fopen(listfilename);
wavname = fgetl(filelist);
count = 1;
while ischar(wavname),
[sig fs header] = read_NIST_file(wavname);
noisy = addnoise(sig',SNR); %'
[a b c] = fileparts(wavname);
write_NIST_file([a,'/',b,'.snr',num2str(SNR),c],noisy,header);
if mod(count,50) == 0
fprintf('.');
end
count = count + 1;
wavname = fgetl(filelist);
end
fprintf('\ncomplete. %d files processed.\n',count-1);
fclose(filelist);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment