Contains scripts to watch for PDF handwritten notes, then performs OCR and converts to obsidian markdown notes.
- Setup environment
conda create --name ocr312 python=3.12
conda activate ocr312
pip install watcher pypdf requests
-
Add info to config.yaml
-
Run script With python without hangup:
nohup python watcher.py --config config.yaml > ocr.log 2>&1 &
Or as a systemd service to start at boot. Example in ocr-watcher.service
sudo systemctl daemon-reload
sudo systemctl enable ocr-watcher.service
sudo systemctl start ocr-watcher.service
This repo is designed to solve a very niche workflow problem: How can I automatically run ocr on handwritten notes (e.g. from a tablet), convert to obsidian style markdown and upload to my vault?
It is specifically designed to work with a Boox Tab Ultra C pro, running syncthing to sync the notebooks folder with a PC. watcher.py watches this folder for a new PDF, then runs Mathpix OCR and saves result to obsidian vault.
The script also works with other PDF notes from other devices, or paper notes scanned using a PDF scanner, as long as they appear in the same folder.
Mathpix API was chosen for its strong latex math and markdown support, allowing direct conversion to an Obsidian friendly format, with a few minimal clean up steps. Add you app and api keys to config.yaml
https://docs.mathpix.com/#request-parameters-for-uploading-pdfs
The script will ignore default boox note file names (starting with "notebook_") as I mostly use these for throw away notes.
If the file name already exists in the Vault (up to a depth of max_depth) then the handwritten notes will be appended to that note. If not, they are appended to the daily note.
This ties in nicely with my automatic naming of papers, where zotero paper pdf are named with the cite key, synced with the tablet, which then creates a note with the same name. Obsidian also makes a note for the paper from a template using citations plugin, also named with the cite key. Handwritten notes will append straight to the papers obsidian note.