anki-csv2ankicards/README.md

2.0 KiB

AnkiAI

AnkiAI is a robust system that converts images containing text into structured Anki cards using Optical Character Recognition (OCR) and OpenAI's GPT-4 language model. Users can quickly generate decks of flashcards from their images for effective study.

Features

  • Converts image content to textual content using OCR.
  • Uses OpenAI's GPT-4 model to structure the content into Anki decks and cards.
  • Outputs the structured content as an Anki package.

Dependencies

  • genanki: Used for creating Anki decks and cards.
  • Pillow: Image processing library.
  • openai: API library for OpenAI's GPT-4 model.
  • flask: Web server to host the service.

Setup and Installation

  1. Clone this repository:

    git clone https://git.rudefox.io/bj/anki-json2ankicards.git
    cd json2ankicards
    
  2. Set up a virtual environment and activate it:

    python3 -m venv venv
    source venv/bin/activate
    
  3. Install the required packages:

    pip install -r requirements.txt
    
  4. Set up the OpenAI API key:

    export OPENAI_API_KEY=your_openai_api_key
    
  5. Run the server:

    python server.py
    

Usage

  1. Start the server as mentioned above.

  2. Use a tool like Postman or curl to send images to http://localhost:5000/deck-from-images as a multi-part POST request.

  3. The server will respond with a downloadable Anki package. Import this into your Anki app and start studying!

Modules

  1. ankiai.py: The main module that orchestrates the flow.
  2. images2text.py: Converts image content into text using OCR.
  3. json2deck.py: Converts structured JSON data into an Anki package.
  4. prompt4cards.py: Uses OpenAI to structure the content into Anki decks and cards.
  5. server.py: Flask server to host the service.

Contributing

Contributions are welcome! Please submit a pull request or open an issue to discuss changes or fixes.

License

MIT License