Skip to content

Instantly share code, notes, and snippets.

@ErikBoesen
Created November 12, 2021 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ErikBoesen/64e95d370959cf34a2312221c31cd5a0 to your computer and use it in GitHub Desktop.
Save ErikBoesen/64e95d370959cf34a2312221c31cd5a0 to your computer and use it in GitHub Desktop.
import ocrspace
import os
import time
filenames = os.listdir('buttery_images')
print(filenames)
api = ocrspace.API()
for filename in filenames:
print(filename)
txt_filename = 'buttery_texts/' + filename.replace('jpg', 'txt')
if os.path.exists(txt_filename):
continue
time.sleep(60)
text = api.ocr_file('buttery_images/' + filename)
with open(txt_filename, 'w') as f:
f.write(text.strip())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment