Skip to content

mguyard/notion-auto-ocr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Notion automated text recognition

This project lets you add text recognition to your Notion through the use of the Microsoft Vision API and Docker.

gif of automatic text recognition by paragraph in Notion gif of automatic text recognition by caption in Notion - From Marc GUYARD

Preconditions

To get started, you need the following:

Installation

This project can installed using Docker or Docker Compose.

Docker example

$ docker run --name some-name-for-your-container -e NOTION_TOKEN=secret_12345678 -e DATABASE_ID=d82973h2kwldj20239e1 -e MICROSOFT_API_KEY=9834023jdsadlawdkwn -e MICROSOFT_ENDPOINT=https://[YOUR_NAME].cognitiveservices.azure.com/ -e SCAN_METHOD=checkbox -e SCAN_FREQUENCY=15 michielvanbeers/notion-auto-ocr

Docker compose example

version: '3'

services:
  notion-auto-ocr:
    image: michielvanbeers/notion-auto-ocr
    restart: unless-stopped
    environment:
      - NOTION_TOKEN=secret_12345678
      - DATABASE_ID=d82973h2kwldj20239e1
      - MICROSOFT_API_KEY=9834023jdsadlawdkwn
      - MICROSOFT_ENDPOINT=https://[YOUR_NAME].cognitiveservices.azure.com/
      - SCAN_METHOD=checkbox 
      - SCAN_FREQUENCY=15 # Optional 

Environment variables

  • NOTION_TOKEN: API token to integrate with Notion. Don't forget to allow your intergration access to your database
  • DATABASE_ID: ID of the database that you want to scan
  • MICROSOFT_API_KEY: Key to access the Microsofy Computer Vision API
  • MICROSOFT_ENDPOINT: Url of your API end-point. Can be retrieved from the Azure Portal
  • SCAN_METHOD: Method used to scan page including new image to parse. Valid value is checkbox or createtime
  • SCAN_FREQUENCY: Optional parameter to set the frequency of scanning for new images to parse. Leave out to do a single run (recommended for testing)

Usage

The script checks if it can find the 'ocr_text' text in image caption or under an image. If it does, it will send the content of the image to Microsoft OCR API and replace the 'ocr_text' by the result in caption or add the result at the end of the current document. When the 'SCAN_FREQUENCY' environment variable is set, it will check if there are any new pages added since the last scan (through the use of setting timestamps).

Creating a Microsoft API key

This section assumes that you already have a Microsoft Azure account. To create your (free) API resource, take the following steps:

  1. Go to https://portal.azure.com/
  2. Click Create a resource
  3. Search for Computer Vision
  4. Click on Computer Vision
  5. Click Create
  6. Set the following:
    • Subscription
    • Resource group (or create new one)
    • Region (nearest region near you)
    • Name (name of your liking)
    • Pricing tier (Free F0)
    • Click the terms checkbox
  7. Click Review + create

Acknowledgements

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 95.7%
  • Shell 3.1%
  • Dockerfile 1.2%