Captcha

A Python library that generates image and audio CAPTCHAs from text.

Library
PyPI
v0.7.1
1,100stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
46/100Fair
Development Activity0
Maintenance20
Community76
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
73/100Good
Architecture72
Code Quality74
Innovation58
Learning Curve88

Captcha is a small Python library for generating image and audio CAPTCHAs. Given a string, it renders a distorted image (with configurable fonts, sizes, and noise) or synthesizes spoken audio, which you can serve to users to distinguish humans from automated bots when submitting forms.

The library keeps two independent modules, captcha.image and captcha.audio, each exposing a simple generator class that returns raw bytes or writes to a file. It has minimal dependencies (Pillow for images) and is designed to drop into web frameworks that need to produce challenge assets on the fly.

What You Get

  • ImageCaptcha for rendering distorted text images with custom fonts, sizes, and noise
  • AudioCaptcha for synthesizing spoken versions of a code from a voice directory
  • Simple generate() (returns bytes) and write() (saves to file) methods on each generator
  • Type hints (py.typed) and minimal runtime dependencies

Common Use Cases

  • Protecting signup, login, or comment forms from automated bots
  • Serving accessible audio CAPTCHAs alongside image challenges
  • Generating challenge assets on demand within a Python web application

Under The Hood

Architecture - The package is intentionally tiny: src/captcha/image.py implements ImageCaptcha, which uses Pillow to draw text with random rotation, warping, noise dots and curves onto a background, and src/captcha/audio.py implements AudioCaptcha, which stitches together per-digit WAV samples from a voice directory (bundled samples live under captcha/data). Both classes expose generate() returning a byte stream and write() persisting to disk.

Tech Stack - Pure Python packaged via pyproject.toml/setup.py, with Pillow as the main runtime dependency for image drawing and standard-library wave/audioop handling for audio assembly. Ships a py.typed marker for type checkers.

Code Quality - The code is compact and readable, ships type hints, and has a tests directory. It is in light maintenance (infrequent releases) but stable given its narrow scope and long track record.

API Design - Developer experience is excellent: import one class, construct it with optional fonts or voice paths, and call generate()/write(). There is almost no boilerplate and the two-module split keeps image and audio concerns cleanly separated.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search