2023-09-11 16:09:18 +00:00
# AnkiAI
2023-09-07 11:26:28 +00:00
2023-09-11 16:09:18 +00:00
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.
2023-09-07 11:26:28 +00:00
## Features
2023-09-11 16:09:18 +00:00
- 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.
2023-09-07 11:26:28 +00:00
2023-09-11 16:09:18 +00:00
## 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.
2023-09-07 11:26:28 +00:00
2023-09-11 16:09:18 +00:00
## Setup and Installation
2023-09-07 11:26:28 +00:00
1. Clone this repository:
```bash
2023-09-11 16:09:18 +00:00
git clone https://git.rudefox.io/bj/anki-json2ankicards.git
cd json2ankicards
2023-09-07 11:26:28 +00:00
```
2. Set up a virtual environment and activate it:
```bash
python3 -m venv venv
source venv/bin/activate
```
3. Install the required packages:
```bash
pip install -r requirements.txt
```
2023-09-08 13:29:15 +00:00
2023-09-11 16:09:18 +00:00
4. Set up the OpenAI API key:
```bash
export OPENAI_API_KEY=your_openai_api_key
```
2023-09-08 09:32:49 +00:00
2023-09-11 16:09:18 +00:00
5. Run the server:
```bash
python server.py
```
2023-09-07 11:26:28 +00:00
## Usage
2023-09-11 16:09:18 +00:00
1. Start the server as mentioned above.
2023-09-08 09:24:37 +00:00
2023-09-11 16:09:18 +00:00
2. Use a tool like [Postman ](https://www.postman.com/ ) or `curl` to send images to `http://localhost:5000/deck-from-images` as a multi-part POST request.
2023-09-08 08:30:05 +00:00
2023-09-11 16:09:18 +00:00
3. The server will respond with a downloadable Anki package. Import this into your Anki app and start studying!
2023-09-07 11:26:28 +00:00
2023-09-11 16:09:18 +00:00
## Modules
2023-09-07 11:26:28 +00:00
2023-09-11 16:09:18 +00:00
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.
2023-09-07 11:26:28 +00:00
2023-09-11 16:09:18 +00:00
## Contributing
2023-09-07 11:26:28 +00:00
2023-09-11 16:09:18 +00:00
Contributions are welcome! Please submit a pull request or open an issue to discuss changes or fixes.
2023-09-07 11:26:28 +00:00
2023-09-11 16:09:18 +00:00
## License
2023-09-07 11:26:28 +00:00
2023-09-11 16:09:18 +00:00
[MIT License ](LICENSE )