mirror of
https://github.com/lepture/captcha.git
synced 2026-03-13 09:43:22 +08:00
docs: update docs
This commit is contained in:
@@ -1,2 +1,51 @@
|
||||
Audio Captcha
|
||||
=============
|
||||
|
||||
.. rst-class:: lead
|
||||
|
||||
Unlock security with Audio CAPTCHA aastery.
|
||||
|
||||
----
|
||||
|
||||
.. module:: captcha.audio
|
||||
:noindex:
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Generating audio CAPTCHA with the :class:`AudioCaptcha`` class is remarkably simple.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from captcha.audio import AudioCaptcha
|
||||
|
||||
captcha = AudioCaptcha()
|
||||
data: bytearray = captcha.generate('1234')
|
||||
|
||||
.. note::
|
||||
|
||||
The default voice library only includes numbers from 0 to 9.
|
||||
|
||||
Voice library
|
||||
-------------
|
||||
|
||||
We can build our customized voice library with the help of ``espeak`` and ``ffmpeg``:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Set the language code
|
||||
export ESLANG=en
|
||||
|
||||
# Create a directory for the specified language code
|
||||
mkdir "$ESLANG"
|
||||
|
||||
# Loop through each character (a-z, A-Z, 0-9) and create a directory for each
|
||||
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
|
||||
|
||||
Web server
|
||||
----------
|
||||
|
||||
@@ -58,6 +58,12 @@ html_theme_options = {
|
||||
'github_url': 'https://github.com/lepture/captcha',
|
||||
"carbon_ads_code": "CE7DKK3W",
|
||||
"carbon_ads_placement": "captchalepturecom",
|
||||
"light_css_variables": {
|
||||
"--sy-rc-theme": "36, 206, 114",
|
||||
},
|
||||
"dark_css_variables": {
|
||||
"--sy-rc-theme": "36, 179, 101",
|
||||
},
|
||||
"nav_links": [
|
||||
{"title": "Sponsor me", "url": "https://github.com/sponsors/lepture"},
|
||||
]
|
||||
|
||||
@@ -1,2 +1,31 @@
|
||||
Image Captcha
|
||||
=============
|
||||
|
||||
.. rst-class:: lead
|
||||
|
||||
Unleash captivating security with image CAPTCHA mastery.
|
||||
|
||||
----
|
||||
|
||||
.. module:: captcha.image
|
||||
:noindex:
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Generating image CAPTCHA with the :class:`ImageCaptcha` class is incredibly straightforward.
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from io import BytesIO
|
||||
from captcha.image import ImageCaptcha
|
||||
|
||||
captcha = ImageCaptcha()
|
||||
data: BytesIO = captcha.generate('ABCD')
|
||||
|
||||
Fonts
|
||||
-----
|
||||
|
||||
Web server
|
||||
----------
|
||||
|
||||
Reference in New Issue
Block a user