This repository contains a suite of Python scripts designed to automate the creation and management of Anki flashcards, specifically tailored for the "4000 Essential English Words" format.
- Auto-Fetch: Automatically retrieves definitions, example sentences, and IPA transcriptions from dictionary APIs.
- Root Fallback: Automatically checks root forms (e.g., "transliterate" for "transliterated") if data or IPA is missing for the specific word form.
- Auto-Image: Searches Pexels for relevant images and uploads them directly to Anki.
- Auto-Audio: Generates high-quality Text-to-Speech (TTS) for words, meanings, and examples using macOS built-in voices (
say) andffmpeg. - AnkiConnect Integration: Pushes cards directly into Anki without manual importing.
- Smart Duplicate Prevention: Checks both your local
4000 Essential English Words.txtand your live Anki collection (including the newMy English Wordsdeck) before adding words. - Auto-Formatting: Automatically bolds the target word in example sentences to match your deck style.
- macOS: Required for the
saycommand (TTS). - Anki Desktop: Must be running for the scripts to talk to your collection.
- AnkiConnect Add-on:
- Open Anki -> Tools -> Add-ons -> Get Add-ons.
- Enter code:
2055492159. - Restart Anki.
- FFmpeg: Required for audio conversion.
brew install ffmpeg
Create a .env file in the root directory:
PEXELS_API_KEY=your_api_key_hereThe primary script. It will fetch data, generate media, and create/update the card in your My English Words deck.
python3 add_word_to_anki.py [word]- If the word exists, it will ask if you want to update it (useful for fixing missing examples or IPA).
- If data is missing from the dictionary, it will prompt you for manual entry during the review phase.
A more flexible version that allows you to specify the deck and prefix via arguments.
python3 anki_tools.py [word] --deck "My English Words" --prefix "user_"--deck: Target deck name (defaults to "My English Words").--model: Note type name (defaults to "4000 EEW").--prefix: Prefix for media filenames (defaults to "user_").
Reliably checks if a word exists in the original 4000 txt file OR your active Anki collection.
python3 check_word.py [word]Run the unit test suite to verify script logic (uses mocks, no internet/Anki required):
python3 test_scripts.pyadd_word_to_anki.py: Standard automation logic.anki_tools.py: Fully dynamic CLI version.check_word.py: Synchronized duplicate checker.get_pexels_image.py: Standalone image downloader.reorganize_decks.py: Utility to move cards between decks.4000 Essential English Words.txt: Base vocabulary reference.
Once cards are added via the scripts:
- Open Anki on your Mac.
- Click Sync (top right).
- Open Anki on your phone and click Sync.
- All text, images, and audio will be synchronized automatically.
Note: This tool is intended for personal use to enhance vocabulary learning workflows.