Skip to content

91-9/ocr-anki

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

OCR-to-Anki CSV Generator using Google Vision

This project converts existing physical or digital cue cards into Anki cue cards by performing OCR on paired question/answer images and generating a .csv for Anki import.


⚙️ Installation

git clone https://github.com/91-9/ocr-anki
cd ocr-anki
pip install google-cloud-vision
  • Python 3.7+ required
  • Google Cloud Vision API enabled

🔐 Google Cloud Setup

  1. Create a project
    Google Cloud Console

  2. Enable the Vision API
    Enable Vision API

  3. Create a Service Account with Editor role
    Service Accounts

  4. Generate a JSON Key file and download it

  5. Set environment variable:

    • PowerShell:
      $env:GOOGLE_APPLICATION_CREDENTIALS="C:\Path\To\key.json"
    • Command Prompt:
      set GOOGLE_APPLICATION_CREDENTIALS=C:\Path\To\key.json

▶️ Usage

  1. Take photos or scans of your cue cards (question and answer sides).
  2. Filenames must reflect the date and time the images were taken, so that their order matches the intended question > answer sequence (e.g., 20250608_120101.jpg, 20250608_120105.jpg, ...).
  3. Ensure images are in time sequence: question image, then answer image, then next question, then next answer, etc.
  4. Run the script:
python ocr_google_vision.py

📤 Output

Generates ocr_output.csv:

Question 1 text, Answer 1 text
Question 2 text, Answer 2 text

Tags or prefixes like 8) or general) are stripped from the question text.


📥 Import into Anki

  1. In Anki, go to File → Import
  2. Select ocr_output.csv
  3. Choose:
    • Field 1 → Front
    • Field 2 → Back
    • Separator: Comma
    • Encoding: UTF-8

✅ Notes

  • The script assumes each question-answer pair is two consecutive images in time order.
  • Filenames must reflect the date/time to ensure correct sequence.
  • Supported image extensions: .jpg, .jpeg, .png.
  • Output does not include tags or headers.

About

Uses Google Cloud Vision to extract text into a csv ready for import into Anki.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages