From 15af7396c83068b578f3904c41d65ccb4ec1747f Mon Sep 17 00:00:00 2001 From: Hsiaoming Yang Date: Sat, 29 Jul 2023 10:08:00 +0900 Subject: [PATCH] docs: update docs --- docs/audio.rst | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ docs/conf.py | 6 ++++++ docs/image.rst | 29 +++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) diff --git a/docs/audio.rst b/docs/audio.rst index 06a7637..c614216 100644 --- a/docs/audio.rst +++ b/docs/audio.rst @@ -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 +---------- diff --git a/docs/conf.py b/docs/conf.py index cfbcdd1..9cdfca1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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"}, ] diff --git a/docs/image.rst b/docs/image.rst index 071616b..a0cfefb 100644 --- a/docs/image.rst +++ b/docs/image.rst @@ -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 +----------