Skip to content
HelloYuiYuiPublic

About

A pipeline to create cloze anki cards.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Ankifier

Ankifier is an AI-assisted flashcard generator to help users speed up their flashcard generation process. Its main strength and function is to take in words in the target language the user may come across during their studies, generate sentences that use the given words, generate audio for the sentence provided or generated, and combine them all into a cloze card in Anki. Currently it only support French, as it is the language I focus on at the moment. In the foreseeable future I intend to expand it to include Bulgarian and German too.

There are three ways of using Ankifier at the moment:

  1. Target word or phrase in a sample AI-generated sentence in cloze format.
  2. Target word, phrase, or sentence with an AI generated sentence in basic format.
  3. Manual entry of front and back values, in cloze or basic format.

It uses Mistral as its text generator model, ElevenLabs for audio generation, and AnkiConnect to add cards to Anki.

This tool is highly optimised for my own personal learning process that combines multiple methods, primarily comprehensible input with some targeted grammar practice. Everyone learns differently, so this may not work for you. Some tips to make the best out of it:

  • This is an assistive tool, not a standalone resource. Engage with your target language, and note down the words you don't know and want to learn.
  • Anki requires long-term determination and commitment to be regular with your learning. Showing up daily is crucial if you want to progress.
  • I found it a motivating factor for continuous study to add at least a few words every day rather adding many words in one day and studying them later. This ensures continuous exposure and input in the target language.

Setup

As AnkiConnect runs locally, we need to run the server locally too in order to add cards to Anki. Once you clone this repository and ensure you have poetry and pnpm, run the following commands on the terminal to download needed dependencies.

poetry install
pnpm install

You will need to fetch your own Mistral and ElevenLabs API keys. Once you get these, create a .env in the repo root:

AI_KEY=...                  # Mistral
ELEVEN_LABS_KEY=...         # ElevenLabs

Once this is set up and you have Anki running with AnkiConnect add-on, on the root directory, run the following command to start the server:

poetry run ankifier

Usage

When given a plain word in generate format, Mistral AI will generate a sentence that uses the given word and its translation, with the target word masked in cloze format. If as-is button is ticked, it will take the given text as is, pass it onto Mistral for translation and ElevenLabs for audio generation.

To generate using your own custom sentence as a cloze card, put your target word or phrase in the sentence between [[...]] and Mistral will generate a translation for the sentence and you'll have a cloze card with the marked section masked.

You type Anki gets
Le [[chat]] dort Le {{c1::chat}} dort
Il faut que tu [[sois:être]] là Il faut que tu {{c1::sois::être}} là
[[a]] et [[b]] {{c1::a}} et {{c2::b}}

Everything after the first colon is the hint Anki shows on the card; a hint is never read aloud.

On the manual page each row has an Audio toggle: Front (the default) reads the sentence you typed, Back reads the text in the Back column instead. Pick Back when hearing the front would give the answer away. It only changes what is spoken: the [sound:...] tag goes on the note's back field either way, so the audio never plays before you turn the card over.

Browser extension

A Chrome extension adds cards while you read, without leaving the page. Select a word and click Card: Mistral writes one card for the meaning the word has in the sentence you selected it from. You can also select a sentence and click As is. Wrap the part to hide in [[...]] before translating, or leave it plain for a front/back card. You review and edit the card in a small bubble on the page, then add it to Anki.

The extension talks to the same local server, so poetry run ankifier and Anki both need to be running. To build and install it:

pnpm build:ext               # writes extension/.output/chrome-mv3

In chrome://extensions, turn on Developer mode, click Load unpacked, and pick extension/.output/chrome-mv3. The toolbar popup shows whether the server, Anki and both keys are ready, and it's where you change the server URL if it isn't http://127.0.0.1:8000. For development, pnpm dev:ext opens a Chrome with the extension loaded and reloads it on every change.

Technical Details

To Do

About

A pipeline to create cloze anki cards.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages