AnkiCardsToolkit automates the creation of rich, bilingual Anki flashcards for effective English vocabulary memorization.
It combines audio pronunciation, imagery, CEFR level, frequency data, and synonym support in a single streamlined workflow.
- 🔊 Generates pronunciation audio using TTS (Text-to-Speech)
- 🖼️ Finds relevant images from the free Pexels library
- 📊 Adds CEFR level and frequency category to the card
- 📖 Fetches dictionary definitions and synonyms
- 🌐 Multi-language user interface (English and Ukrainian supported)
- 🧠 Focused word memorization from full sentence context
- 📋 Automatically reads the sentence from the clipboard
- ⚙️ Smart command-line interface with interactive prompts and robust error feedback
- 🪄 Generates ready-to-use HTML front/back templates for Anki
This tool is ideal for English learners and language autodidacts who want full control over the content of their vocabulary cards.
- 🖼️ Screenshots
- ⚙️ User Interaction Workflow
- 🛠️ Installation
- ➤ For Linux/macOS:
- ➤ For Windows:
- ➤ Generate 1-second Silent Audio
- ➤ NLTK resources
- ➤ Environment Configuration
- ➤ Enable Image Support (Pexels API)
- ➤ Enable Word Associations (Big Huge Thesaurus API)
- ➤ Using the Card Templates in Anki
- ➤ Required Fields in Anki
- ➤ Deck Selection and Persistence
- ➤ Optional: Generating a Custom Silence MP3
- 🚀 Running the Toolkit
- 🌐 Set the Language (Optional)
- 📡 Internet Access, Anki Profile & Media Storage
- 📊 CEFR & Frequency Integration
- 🎓 Best Practices for Using This Toolkit with Anki
- 🧾 License
Here’s what your flashcards will look like:
🔹 Front side
Shows the sentence with the focus word highlighted and audio playback.
🔸 Back side
Includes:
- The same sentence
- Relevant image
- Focus word with:
- Pronunciation & transcription
- CEFR level and frequency band
- Dictionary definition
- Synonyms, related/similar words, antonyms
- Ukrainian translation
This is what a typical interaction looks like when generating a new flashcard from a sentence:
(venv) $ python3 generate_card.py
Enter deck name [Default]:
📋 Copied sentence:
Roman history is the story of the Romans’ conquest of Italy and the entire Mediterranean world.
Is it correct? [Press Enter to confirm or type again]:
🔤 Enter the word you want to study: conquest
📝 Part of speech [noun] [Press Enter to confirm or change (noun/verb/adjective/adverb)]:
🔍 Querying Big Huge Thesaurus for 'conquest'...
✅ Received response from Big Huge Thesaurus
🔍 Searching for relevant images...
✅ Found 16 images — opening browser preview...
🔢 Enter a number (1–16) or press Enter to skip: 6
✅ Image selected successfully📝 Enter the Ukrainian translation:
🔤 Enter translated words (separate with commas)): завоювання, підкорення
📁 File tts_conquest.mp3 saved
📁 File tts_sentence_conquest.mp3 saved
✅ Card added: ID = 1749913745076To get started, clone the repository and set up a virtual environment:
git clone https://github.com/OlegOKovalyov/anki-cards-toolkit.git
cd anki-cards-toolkit
# Create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate
# Install project dependencies
pip install -r requirements.txtgit clone https://github.com/OlegOKovalyov/anki-cards-toolkit.git
cd anki-cards-toolkit
:: Create and activate a virtual environment
python -m venv venv
venv\Scripts\activate
:: Install project dependencies
pip install -r requirements.txt✅ Tip: Make sure to activate the virtual environment each time you work on the project or run the app:
source venv/bin/activate # on Linux/macOS
venv\Scripts\activate # on Windowsℹ️ Note: After activating the virtual environment, your terminal prompt should look like this:
(venv) user@machine:~/anki-cards-toolkit$This indicates that you're working inside the virtual environment.
To add a natural pause between sentence and word in the flashcard audio, run:
python scripts/generate_silence.pyThis will create a 1-second silent MP3 used automatically in all cards.
This project uses NLTK lemmatization (WordNet).
After installing dependencies, run the following once:
python scripts/install_nltk_data.pyBefore using the app, create a .env file in the project root with the following content:
MODEL_NAME=VocabCard_English_UA
DECK_NAME=Default
PEXELS_API_KEY=your_pexels_api_key
BIG_HUGE_API_KEY=your_big_huge_thesaurus_key
ANKI_CONNECT_URL=http://localhost:8765
CONFIG_FILE=last_deck.txt
USER_LOCALE=uk🗂️ The .env file is ignored by Git (via .gitignore) and must not be committed.
💬 USER_LOCALE controls interface language (uk, en, etc.). If not set, the app will ask you to choose a language on first launch.
🔧 Configuration is loaded using the python-dotenv package.
To automatically fetch images from Pexels.com:
- Create a free account and get your API key.
- Add it to your
.envfile:PEXELS_API_KEY=your_actual_pexels_api_key_here
To fetch synonyms and related words:
- Get a free API key at words.bighugelabs.com.
- Add it to your
.envfile:BIG_HUGE_API_KEY=your_api_key_here
The project includes two HTML templates in /templates/:
- front_template.html — front side of the card
- back_template.html — back side of the card
To use them in Anki:
-
In Anki, go to Browse → Cards (or press Ctrl+L)
-
Create a new card type (based on “Basic”) 🔒 Important: The card type name must be exactly
VocabCard_English_UA -
Copy the contents from the two files into the Front Template and Back Template tabs
💡 The back side includes a silent audio
[sound:silence_1sec.mp3]to add a natural pause before the focus word:
<div style="display: none;">
<!-- Adding a silent audio file to create a pause -->
[sound:silence_1sec.mp3]
</div>Your custom card type VocabCard_English_UA must contain specific fields so the toolkit can insert all generated content correctly.
📋 Create these fields (in this order recommended by the project):
Word(⚠️ Should be first — required by Anki to avoid empty note errors)SentenceSentence_AudioDefinitionSynonymsRelatedSimilarAntonymsSentence_RepeatedImageIrregular_Forms(optional, for irregular verbs)Word_AudioDictionary_EntryTranslation_UAFront(Anki default — not used by this toolkit)Back(Anki default — not used by this toolkit)
🛠️ How to add fields:
- Open Anki → Browse → Cards
- Click Fields...
- Add fields manually in the listed order
💡 Tip: Anki skips empty fields automatically, so optional data won’t break your templates.
The toolkit lets you choose an Anki deck dynamically when creating a card.
🧠 What happens:
- You'll be asked to type the Anki deck name manually.
- The last used deck (stored in
last_deck.txt) is suggested as default. - If the deck doesn’t exist, it will be created automatically.
💡 Just press Enter to reuse the previous deck name — perfect for batch card creation.
Example deck names:
English - Mood FoodHistory - Chapter 01
By default, the app uses a 1-second silent MP3 for smooth audio playback. To change the pause duration, edit the scripts/generate_silence.py script:
generate_silence(duration_ms=2000) # ← 2 secondsThen re-run the script to regenerate the file:
python scripts/generate_silence.pyBefore generating Anki flashcards, make sure everything is ready:
Download and install Anki from the official site:
👉 https://apps.ankiweb.net/
🟢 Important: Anki must be running in the background during flashcard generation.
This toolkit communicates with Anki via AnkiConnect.
📦 To install:
- Open Anki
- Go to
Tools → Add-ons → Get Add-ons… - Paste this code:
2055492159 - Click OK and restart Anki
🟢 After installation, AnkiConnect listens at http://localhost:8765
Make sure:
- Anki is running
- AnkiConnect is installed and enabled
- You’re connected to the internet
Then run:
source venv/bin/activate # or venv\Scripts\activate.bat on Windows
python generate_card.pyYou can choose the interface language (English or Ukrainian) using:
python generate_card.py --set-languageOr the short version:
python generate_card.py -lIf the language is not set, the app will prompt you to choose one on the first launch.
Your preference will be saved in the .env file as USER_LOCALE.
This toolkit requires an active internet connection to:
- Get synonyms and definitions (Big Huge Thesaurus)
- Fetch images (Pexels)
- Generate audio (TTS)
By default, Anki uses a profile called User 1.
All media (audio, images, silence) is saved in:
• Linux/macOS:
~/.local/share/Anki2/User 1/• Windows:
C:\Users\<YourUsername>\AppData\Roaming\Anki2\User 1\💡 If you rename your profile in Anki, the folder name will change accordingly.
The tool uses gTTS (Google Text-to-Speech) to generate two audio files per card:
tts_<word>.mp3tts_sentence_<word>.mp3
🗂️ Saved to Anki's media folder:
~/.local/share/Anki2/User 1/collection.media/🗑️ If a card is deleted or updated, audio may be moved to:
~/.local/share/Anki2/User 1/collection.media/media.trash/Anki cards display images using direct links from Pexels.
Images are not downloaded, only embedded via URL.
💡 This means:
- No local storage is used
- Internet is required during card review
Example snippet:
<img src="https://images.pexels.com/..." style="width:100%; height:100%; object-fit:contain;">Unsatisfied with the auto-selected image?
You can easily change it in Anki:
- Open the card in Edit mode.
- Replace the
<img src="...">link with any valid image URL.
Example:
<img src="https://example.com/custom-image.png">✅ Your image will now be shown during flashcard reviews.
❗ If you enter a focus word that already exists as the front side of a card in any deck, Anki will prevent the creation of a duplicate card and return an error. This is default behavior of AnkiConnect to avoid unintended duplicates across your entire collection.
❗ If at any point something goes wrong — e.g., you mistakenly enter a focus word instead of confirming the sentence — you can safely stop the process with
Ctrl+C. This allows you to restart from the beginning without creating a broken or incomplete card.
Each word in your flashcards is enriched with:
- CEFR level (A1–C2)
- Frequency category (1–9)
This data comes from a merged file: data/merged_cefr_frequency.csv.
It is used automatically during card creation.
The merged file is created from two open-source CSVs:
word_list_cefr.csvvalid_words_sorted_by_frequency.csv
Source:
Maximax67 / Words-CEFR-Dataset
To regenerate the merged file:
cd data/
wget https://raw.githubusercontent.com/Maximax67/Words-CEFR-Dataset/main/csv/word_list_cefr.csv
wget https://raw.githubusercontent.com/Maximax67/Words-CEFR-Dataset/main/csv/valid_words_sorted_by_frequency.csv
python3 merge_cefr_and_frequency.py🧮 Output format
Word,CEFR,Frequency
abandon,B2,4
about,A1,2
acquaintance,?,6- CEFR: A1–C2 or ? if not found
- Frequency: Category from 1 (most frequent) to 9 (rare)
| Category | Frequency Range |
|---|---|
| 1 | 10,000 – 17,000 |
| 2 | 17,000 – 30,000 |
| 3 | 30,000 – 50,000 |
| 4 | 50,000 – 100,000 |
| 5 | 100,000 – 170,000 |
| 6 | 170,000 – 300,000 |
| 7 | 300,000 – 800,000 |
| 8 | 800,000 – 3,000,000 |
| 9 | 3,000,000 and above |
⚠️ Only the final merged file is committed to the repo. Source CSVs and merging script are kept locally (not versioned).
To make the most of your vocabulary learning with Anki and this toolkit, consider the following workflow and usage tips:
-
📋 Copy a sentence to your clipboard from any source: textbook, article, video, podcast, etc.
-
▶️ Run the script:python3 generate_card.py
-
🗂️ Enter the deck name:
- Press Enter to reuse the previous deck
- Or type a new one manually
⚠️ Do not copy the deck name — the clipboard should contain only the sentence. -
🎯 Choose your focus word — the one you want to learn.
-
🧠 The toolkit builds a flashcard using the VocabCard_English_UA type, with:
- Sentence (with TTS audio)
- Focus word (with translation, definition, CEFR & frequency)
- Synonyms, antonyms, related words
- Image (optional)
- Word and sentence audio (with pause)
🔖 Example Deck Names
Group flashcards by topic or source for better review:
- English File – Unit 2
- TV Series – Breaking Bad
- History – Ancient Egypt
- Podcast – VOA Learning English
- Movie – The Matrix
▶️ In Anki, click "Study Now" to begin reviewing your deck.- 📖 Read the sentence, recall the focus word’s meaning, then click "Show Answer".
- 🧠 Rate your recall:
- 🔁 Again – you forgot or struggled
- 😬 Hard – barely remembered
- 🙂 Good – recalled with effort
- 😎 Easy – instant and effortless
Anki will schedule future reviews using spaced repetition based on your response.
- 📅 Add 5–10 new cards per day for steady progress.
- 🔄 Review due cards daily, even if you skip adding new ones.
- 🎯 Prioritize meaningful sentences over memorizing single words.
This project is licensed under the MIT License. See the LICENSE file for details.
CEFR & frequency data by Maximax67/Words-CEFR-Dataset is used with attribution under its open license — with thanks to the author.



