Skip to content

Conversation

@Nachasic
Copy link

@Nachasic Nachasic commented Sep 22, 2022

Thank you for this incredible tool!

I've tried using it for my math study workflow, where I need to transcribe lots of math from textbooks, websites and handwritten notes. A specific workflow I had in mind:

  1. Grab a screenshot of a sceen area;
  2. Feed the screenshot to LaTeX-OCR;
  3. Grab the LaTeX prediction from stdout and pipe it into my clipboard.

Unfortunately, the CLI turned out to be barely usable for me: when calling pix2tex --file pic.png the utility shows the interactive TUI instead of processing the file right away, so I came up with two changes to fix this:

  1. Remove checks for arguments.gnome from main (my python env was complaining about gnome being absent from the arguments namespace);
  2. Remove interactive TUI from the CLI

You can see the resulting workflow on this gif:
Peek 2022-09-22 11-19

The bash script I'm using:

#!/usr/bin/bash

# Create a temporary directory
TEMP_DIR=$(mktemp -d) 

# Grab an area screenshot and save it to temp folder
flameshot gui --path $TEMP_DIR/pic.png

# Feed the screenshot to pix2tex and pipe the prediction to clipboard
pix2tex --file $TEMP_DIR/pic.png | xclip -sel clip

# pix2tex takes a couple seconds to process, notify me when done
notify-send "GrabTeX" "TeX is copied to clipboard"

# Remove the temporary directory
rm -rf $TEMP_DIR

I would love to make a contribution that enables this kind of workflow for anybody, but I'm pretty new to Python development. Please let me know if there is anything else I should do in this PR in order for it to get merged.

@Nachasic
Copy link
Author

Closing in favor of #187

@Nachasic Nachasic closed this Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant