Skip to content
PrParadoxyPublic

About

AnkiDict is a programmable vocabulary card generator for Anki, powered by local LLMs.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

16 Commits

Folders and files

Repository files navigation

AnkiDict

AnkiDict is a programmable vocabulary card generator for Anki, powered by local LLMs.

Screenshot

It supports two complementary workflows:

  • Interactive Mode – generate a single dictionary card while reading by selecting a word and pressing a global hotkey.
  • Batch Mode – generate thousands of cards from any Python iterable using the provided batch API.

AnkiDict uses llama.cpp for local LLM inference, AnkiConnect for creating notes in Anki, and automatically generates pronunciation audio for every card using edge-tts.


Table of Contents


Features

  • 📖 Dictionary-style vocabulary cards
  • ⚡ Interactive hotkey workflow
  • 🤖 Local LLM inference with llama.cpp
  • 🔊 Automatic pronunciation audio using edge-tts
  • 📦 Batch generation from arbitrary Python iterables
  • 🎨 Flexible prompts and note templates
  • 🔧 Easily customizable pipeline

Requirements

Before using AnkiDict, install:

  • Python 3.10+
  • Anki
  • AnkiConnect
  • llama.cpp
  • A GGUF model compatible with llama.cpp

For the interactive workflow:

  • Windows: AutoHotkey
  • Linux: a desktop keyboard shortcut capable of running a shell command

Installation

1. Clone the repository

git clone https://github.com/PrParadoxy/ankidict.git
cd ankidict

Or you can download the whole project as a Zip file by clicking on Code > Local > Download Zip and extract the archive. The Code green button can be found on top of the project.

2. Install Python dependencies

pip install -r requirements.txt

3. Install AnkiConnect

AnkiDict communicates with Anki through AnkiConnect.

  1. Open Anki.
  2. Go to Tools → Add-ons → Get Add-ons...
  3. Install the AnkiConnect add-on.
  4. Restart Anki.

Anki must be running while cards are being generated.

4. Install llama.cpp

Download a prebuilt release of llama.cpp from:

https://github.com/ggml-org/llama.cpp/releases

Extract the archive and make sure the llama-server executable can be run from your command line.

  • Windows: Add the folder containing llama-server.exe to your system PATH.
  • Linux: Add the directory containing llama-server to your PATH (or place it somewhere already on your PATH, such as /usr/local/bin).

Next, download a GGUF model of your choice.

Open

config.yaml

and set the MODEL_PATH to your GGUF model.

Refer to the comments in config.yaml for a description of all available configuration options.


Interactive Mode

Interactive Mode creates a single card from the currently selected word.

Internally, the workflow simply executes

python -m src.generate "<selected word>"

The only platform-specific component is how the selected text is passed to this command.

Windows

The repository includes an AutoHotkey launcher.

  1. Install AutoHotkey:

https://www.autohotkey.com/

  1. Run the provided AutoHotkey script word_capture.ahk.

The default hotkey is

Ctrl + Alt + G

Selecting a word and pressing the shortcut opens a card editor populated with AI-generated content. You can review and modify any field before confirming, at which point the note is added to your chosen Anki deck.

Linux

Install xclip (X11)

sudo apt install xclip

or wl-clipboard (Wayland)

sudo apt install wl-clipboard

Then create a Custom Keyboard Shortcut in your desktop environment (GNOME, KDE, Xfce, etc.).

For X11, use the command

bash -lc 'cd /path/to/ankidict && python -m src.generate "$(xclip -o -selection primary)"'

For Wayland, use

bash -lc 'cd /path/to/ankidict && python -m src.generate "$(wl-paste)"'

Assign your preferred shortcut (for example Ctrl + Alt + G).

No terminal window will appear—the command is executed directly by your desktop environment.


Pronunciation Audio

Every generated note includes pronunciation audio created using edge-tts.

The TTS voice is configurable, making it easy to select different languages, accents, or voices depending on your target language.

Note

LLM inference is performed entirely locally using llama.cpp. Pronunciation audio is generated through edge-tts, which requires an Internet connection.


Batch Mode

For generating many cards programmatically, use the batch API located in

src/batch.py

The batch API accepts arbitrary Python iterables, allowing cards to be generated from both small collections and very large datasets.

Typical use cases include

  • frequency lists
  • dictionaries
  • subtitle vocabularies
  • textbook vocabulary
  • corpora
  • custom datasets

A complete example is available in

example/derewo.py

which demonstrates generating the 10,000 most common German words from the DeReWo frequency list.

About DeReWo

The DeReWo word list is not part of AnkiDict. It is included solely as an example dataset demonstrating how to use the batch API.

DeReWo is distributed by the Institut für Deutsche Sprache (IDS) under the Creative Commons Attribution–NonCommercial 3.0 (CC BY-NC 3.0) license.


Customization

AnkiDict is intended to be easily adapted to different languages and workflows.

You can customize:

  • LLM prompts
  • note templates (including HTML/CSS/JavaScript)
  • generated fields
  • TTS voice
  • the interactive launcher
  • the batch processing pipeline

Most configuration is performed through

config.yaml

Every configurable option is documented directly in the file with explanatory comments.

Among other things, you can configure:

  • the llama.cpp executable path
  • the GGUF model path
  • LLM generation parameters
  • prompt templates
  • Anki deck and note type
  • field mappings
  • the edge-tts voice
  • output formatting
  • generation options

For most users, config.yaml is the only file that needs to be edited to adapt AnkiDict to a different language, model, or Anki setup.

Custom note type

Custom Anki note types can be generated directly from the configuration by running

python src/template.py

The generated note type reflects the fields, templates, and styling defined in config.yaml, making it easy to create custom card layouts without manually editing Anki note types. *.css and *.js files must be placed under asset folder. The template is generated by Ganki as an .apkg file which can be easily installed on Anki software.


Related Projects

anki-llm

A Rust implementation for LLM-powered Anki card generation.

Compared to AnkiDict:

  • more mature project
  • more strict workflow
  • less flexible note template customization
  • Written in Rust (AnkiDict is fully written in python)

Repository:

https://github.com/ospalh/anki-llm


anki-mcp

A mature Model Context Protocol (MCP) server for Anki.

Compared to AnkiDict:

  • general-purpose Anki API
  • excellent for automation and AI assistants
  • supports many Anki operations beyond vocabulary generation

If you are looking for a programmable interface to Anki rather than an out-of-the-box vocabulary generator, anki-mcp is likely the better choice.

Repository:

https://github.com/steven-kraft/anki-mcp


License

This project is licensed under the MIT License.


Contributions, suggestions, and pull requests are always welcome.

About

AnkiDict is a programmable vocabulary card generator for Anki, powered by local LLMs.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages