Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
audio CAPTCHA demo for GNU Octave
% makeaudio.m
% 2010-07-16 by nishimotz@gmail.com
% http://www.slideshare.net/nishimotz/nishimoto-icchp2010
FILEBODY = "festival-en-00705-kal";
POSTFIX = "99";
RATIO = 0.99; % Exposed ratio
[D,SF] = wavread(strcat(FILEBODY,".wav"));
PERIOD = SF * 0.1; % 100ms period
Mask = [ones(ceil(PERIOD * RATIO), 1); zeros(ceil(PERIOD * (1-RATIO)), 1)];
Dmask = zeros(length(D),1);
for I = 1:length(D)
Dmask(I) = Mask(mod(I,PERIOD)+1);
end
Ddel = D .* Dmask;
wavwrite(Ddel,SF,strcat(FILEBODY,"-del-",POSTFIX,".wav"));
Drand = rand(length(D),1) .* 2 - 1;
Dpr = D .* Dmask + Drand .* (1-Dmask) .* max(D) .* 0.10;
wavwrite(Dpr,SF,strcat(FILEBODY,"-pr-",POSTFIX,".wav"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment