Skip to content

python script that pulls a snippet from the clipboard and turns it into text.

Notifications You must be signed in to change notification settings

capitanbarbosa/snippet2text

Repository files navigation

Snippet2Text (OCR)

Grabs the latest image from the clipboard (any snip from the screen) and transforms it to text. Finally, it places the text inside the clipboard ready to be pasted, in milliseconds.

A radial menu will be used to launch the script easily. Though the use of it is not obligatory for snippet2text to work.

  • note* We can also use tools such as Windows Power Toy’s “Text Extractor” in the same fashion. But, it is less accurate, has no regexp version, and there is a minimum window snap size (meaning we cannot convert small images containing a very short string.)

Tech Stack / Tools:

Let’s go:

  1. Download and install Tesseract OCR from Mannheim University Library. → https://digi.bib.uni-mannheim.de/tesseract/

  • For Mac, you can use: brew install tesseract pip install Pillow pytesseract pyperclip brew install pngpaste
  1. Once installed, we get our script. → https://github.com/capitanbarbosa/snippet2text

    • There’s 2 versions of Snippet2Text included:
      • one with a Regexp that removes any special chars such as -./() (useful for bank inscriptions, form transcription…)
      • one without a Regexp; it transforms the text image as-is. (useful for copying code from anywhere; youtube, etc.)
  2. Get AutoHotMenu pie menu → create a menu, set up keyboard shortcut.

  3. Call the snippet2text script from the shortcut.

snippet2text-demoVid

Extract any image to text, from anywhere in seconds. | Integrating Tesseract OCR via a shortcut on Windows with python and pytesseract.

About

python script that pulls a snippet from the clipboard and turns it into text.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages