Skip to main content

A captcha library that generates audio and image CAPTCHAs.

Project description

A captcha library that generates audio and image CAPTCHAs.

Donate lepture Become a Patreon https://travis-ci.org/lepture/captcha.svg?branch=master https://ci.appveyor.com/api/projects/status/amm21f13lx4wuura?svg=true https://coveralls.io/repos/lepture/captcha/badge.svg?branch=master

Features

  1. Audio CAPTCHAs DEMO

  2. Image CAPTCHAs

https://cloud.githubusercontent.com/assets/290496/5213632/95e68768-764b-11e4-862f-d95a8f776cdd.png

Installation

Install captcha with pip:

$ pip install captcha

Usage

Audio and Image CAPTCHAs are in separated modules:

from captcha.audio import AudioCaptcha
from captcha.image import ImageCaptcha

audio = AudioCaptcha(voicedir='/path/to/voices')
image = ImageCaptcha(fonts=['/path/A.ttf', '/path/B.ttf'])

data = audio.generate('1234')
audio.write('1234', 'out.wav')

data = image.generate('1234')
image.write('1234', 'out.png')

This is the APIs for your daily works. We do have built-in voice data and font data. But it is suggested that you use your own voice and font data.

Voices

We can build our customized voice library with the help of espeak and ffmpeg:

export ESLANG=en

mkdir $ESLANG

for i in {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9}; do mkdir $ESLANG/$i; espeak -a 150 -s 100 -p 15 -v$ESLANG $i -w $ESLANG/$i/orig_default.wav; ffmpeg -i $ESLANG/$i/orig_default.wav -ar 8000 -ac 1 -acodec pcm_u8 $ESLANG/$i/default.wav; rm $ESLANG/$i/orig_default.wav; done

Contribution

We need voice wav files. The voice wav file should be in 8-bit, please keep it as small as possible. Name your voice file as:

{{language}}-{{character}}-{{username}}.wav
# example: zh-1-lepture.wav

TODO: we need a place to upload voice files.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

captcha-0.4.tar.gz (103.0 kB view details)

Uploaded Source

Built Distribution

captcha-0.4-py3-none-any.whl (102.5 kB view details)

Uploaded Python 3

File details

Details for the file captcha-0.4.tar.gz.

File metadata

  • Download URL: captcha-0.4.tar.gz
  • Upload date:
  • Size: 103.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for captcha-0.4.tar.gz
Algorithm Hash digest
SHA256 2ae5e8daac4f1649b57b34328bcc45ba691b5c707fc6fbdd016e213aece9a8b8
MD5 c23404494fff6338f98f20b3216cfe70
BLAKE2b-256 3d98b2d411b48c8ddab380bb529895e4c6f451206ea47bef2c43324d6422dd06

See more details on using hashes here.

File details

Details for the file captcha-0.4-py3-none-any.whl.

File metadata

  • Download URL: captcha-0.4-py3-none-any.whl
  • Upload date:
  • Size: 102.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for captcha-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 529941705c01c20143d030805f82a362ba5a2af898e59426acc2c8d649ba034c
MD5 fd2be774e9d83aa1ca0b78ae78763548
BLAKE2b-256 11b0a5125b88c185586afc64ea6af894eab996de4ef28c395dcdf4a7818a9098

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page