A simple tool to generate Anki flashcards for learning Chinese.
Set your OpenAI API key in .env
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxAdd phrases to the phrases.txt file in English or Chinese. File can be a mix of both. Phrases just need to be newline separated.
To run:
python cardgen.pyYou can additionally specificy a particular input file using the --filename flag.
python cardgen.py --filename my_phrases.txtIf you wish to use elevenlabs to generate audio, you will need to set the XI_API_KEY environment variable.
To run with elevenlabs, use the --eleven flag.
To use in Anki, click Import File and select flashcards.txt.
To get the audio working correctly, you will need to add the audio files in the generated zhaudio folder to Anki's collection.media folder.
open ~/Library/Application\ Support/Anki2/User\ 1/collection.mediaIt's a bit annoying but if you want the to use the audio on mobile, the collection.media folder cannot have nested directories, so you just have to move the files from zhaudio to the top level.
This generates two types of flashcards:
Happy hunting!

