I recently started to learn a new language. I personally find flashcards very useful for learning new words with the help of spaced repetition. However, creating the cards can take a significant amount of time.

So I took this opportunity to play around a bit with AI APIs to enhance my learning.


First, I need a base list of words that I want to train. An effective way to do this is to ask the AI to come up with words, but it is also possible to simply let the AI generate the list.

For instance, this is the output of openai's language model text-davinci-003 when asking it about Swedish verbs:

Here are the 20 most common Swedish verbs, in order of frequency:

att vara (to be)
att ha (to have)
att göra (to do, make)
att säga (to say)
att se (to see)
att få (to get, receive)
att komma (to come)
att vilja (to want)

In other words a good list.

Generating flashcard answer:

Next I needed to generate the response. With the help of the python package openai, generating this response was extremely easy.

For instance, to generate the answer for a flashcard of a Italian verb the input to the model is

Answer a flashcard of the Italian verb '{word}', and list a few example sentences (The Italian part of the example must be surrounded by quotes). Also, give examples of the different possible conjugations, and say if it is a regular or irregular verb.

The output for the word "to prefer" give the following output:

Answer: Preferire is an irregular Italian verb meaning to prefer.

Present Tense Conjugations:
- io preferisco
- tu preferisci
- lui/lei preferisce
- noi preferiamo
- voi preferite
- loro preferiscono

Example Sentences:
Io preferisco il gelato al cioccolato. ( I prefer ice cream to chocolate.)
Tu preferisci una tazza di caffè? ( Do you prefer a cup of coffee?)
Lui preferisce una birra. ( He prefers a beer.)
Noi preferiamo uscire a cena stasera. ( We prefer to go out for dinner tonight.)
Voi preferite una pizza o una pasta? ( Do you prefer a pizza or a pasta?)
Loro preferiscono andare in vacanza al mare. ( They prefer to go on vacation to the beach.)

Fantastic, so I just had to do this for every word in my list and save the result in a JSON file.


The backend is a python flask server. The server provides access to a spaced learning state machine I wrote. A history of the answers and the cooldown time is stored with each card.


I created a reactive front end to interact with the cards and to provide support for text-to-speech (TTS). The front end is based on bootstrap, and since it's a very light application, I just opted to go for jquery for DOM manipulation.

Text to speech

An important aspect of the output of my language model is that the examples have to be surrounded by quotes. When the flashcard is loaded, it is parsed for these quotes, and a link for playing the example using the browser's TTS engine is injected into the site.

Image not found

Source Code and Example