Skip to content

Instantly share code, notes, and snippets.

@nishimotz
Created July 16, 2010 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nishimotz/478179 to your computer and use it in GitHub Desktop.
Save nishimotz/478179 to your computer and use it in GitHub Desktop.
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