Home

Grammar Flashcard Generator

Personal Project


Python OpenAI API DeepL ElevenLabs Anki

I made this as a tool as an alternative to reading through a grammar book. It generates flashcards tailored to the difficulty level specified by the user, a translation, audio, and a grammar question and answer, and a fun-fact about that particular sentence structure (such as phrasal verbs, or common expressions).


The user sets:

  1. How many flashcards to generate
  2. The difficulty level of the question according to CEFR scale. (Such as A1, B2, etc. The user can also set a multiple difficulties (ex: A1, A2, B2))
  3. The language they are learning
  4. The desired language of the translations

The rest will be handled automatically.

The user can also customize the instructions sent to the agent if they wish. There are also language-specific instructions that can be appended for fine-grained control (for example, I included a list of grammar concepts that I would like covered at different difficulty levels for German.)

How do we know we can trust what AI produces?

This is a crucial question - since we are language learners, most of the time we wont recognize mistakes since we havent learned the language well enough.


To answer this (at least for German) I sent a small survey out to some German native speakers (n=8), and asked them to evaluate:

  1. If the sentences are proper, grammatically correct German
  2. If the sentences are an appropriate difficulty for the stated CEFR language level

Their answers were encouragingly positive! They rated all sentences (~15) as either mostly-appropriate or completely-appropriate for the specified difficulty level, and only a few sentences had minor errors. These minor errors only occured at a C1, near-native level. A1-B2 level sentences were considered perfect by native reviewers.


After the user sets their preferences, the program splits the number of desired flashcards evenly according to how many difficulty levels the user set, and uses a combination of OpenAI API, DeepL Translations, and ElevenLabs Text-To-Speech (TTS) to generate the following:

  1. A sentence suitable for the difficulty level
  2. A grammar question & answer pair, suitable for the difficulty level
  3. Audio file of the sentence being spoken, which is automatically added to the users Anki Media folder (so cards can access it)
  4. A ready-to-import Anki deck for each specified difficulty level, making it easy to focus on grammar at each stage of the language learning process.



Chart for word freq

A flow chart of how the program works

Front of flashcard Back of flashcard

An example of the imported Anki cards (Front, Back) using the template I provided