The PDF to Anki Card Generator is designed to convert text from PDF files into Anki flashcards. It processes the PDF content in chunks and utilizes OpenAI's GPT models to generate question-answer pairs suitable for flashcard-based learning.
In order to set your environment up to run the code here, first install all requirements:
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
export OPENAI_API_KEY=your_api_key_here
export PDF_FILE_PATH=/path/to/your/pdf.pdf
export FLASHCARDS_FILE_PATH=/path/to/your/flashcards.txt
-
Prepare PDF File: Place your PDF file(s) in the SOURCE_DOCUMENTS folder. If you've set a custom PDF_FILE_PATH, ensure your PDF is located at that path.
-
Run the Script
python pdf2anki.py
-
Import generated txt file into Anki
- The script divides the PDF into smaller chunks for processing. Depending on the length and complexity of your PDF, the script may take some time to execute.
- The format of generated flashcards depends on the responses from the OpenAI API. You might need to adjust the prompts or post-process the output for your specific needs.
- Ensure your OpenAI API key has sufficient quota and permissions for GPT model usage.