# AnkiAI - Automated Anki Deck Creator AnkiAI is a tool that leverages OCR (Optical Character Recognition) and GPT-3's powerful natural language processing capabilities to automatically generate Anki decks from images containing text. ### Overview - AnkiAI is designed to streamline the process of creating Anki decks from images. - The core idea is to use OCR to extract text from images and then use GPT-3 to transform this text into a structured Anki deck format. - Users can make a POST request to a Flask server endpoint with their images to receive the Anki deck (.apkg file). ### Directory Structure - `.vscode/`: Contains configuration for VSCode debugger for Flask applications. - `ankiai.py`: The main script that drives the creation of Anki decks from images. - `constants.py`: Contains constant variables used across the project. - `deck_creation.py`: Contains logic for communicating with OpenAI's API and deck creation using genanki. - `image_processing.py`: Processes images, converting them for OCR and then performing OCR to extract text. - `logging_config.py`: Logging configuration for the entire project. - `server.py`: Flask server that provides an API endpoint to upload images and get back an Anki deck. ### Requirements To run AnkiAI, you'll need to have the following dependencies installed: ``` genanki==0.8.0 Pillow openai flask ``` You can install these via `pip` using the `requirements.txt` file: ```bash pip install -r requirements.txt ``` ### How to Run 1. **Environment Variables**: Make sure to set the `OPENAI_API_KEY` environment variable to your OpenAI API key. 2. **Run the Flask server**: ```bash python server.py ``` This will start the Flask server. You can then make a POST request to `http://localhost:5000/deck-from-images` with your images to get an Anki deck. 3. **Run Directly**: If you prefer not to use the Flask server, you can also run `ankiai.py` directly: ```bash python ankiai.py ``` ### How to Debug (VSCode Users) - Open the project in VSCode. - Set up your breakpoints. - Use the VSCode debugger and select "Python: Flask" to start debugging the Flask server. ### Important Notes - **API Key**: For the project to work, it is essential to have the `OPENAI_API_KEY` environment variable set. - **Image Types**: Currently, the image processing module supports PNG, JPG, and JPEG formats. - **Output**: The output `.apkg` file (Anki package file) will be named `out.apkg`. ### Acknowledgements This project heavily relies on the `openai` library for processing and the `genanki` library for deck generation. ### Contributions Contributions are always welcome. Please create a new issue or a pull request for any bug fixes or feature requests.