Last active
December 5, 2022 20:34
-
-
Save samvarankashyap/64cc7a26e1413a2ee1d950170e30ac20 to your computer and use it in GitHub Desktop.
png2text_telugu.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
క్ర” చిక్కియున్నవేళ సింహంబునైనను | |
బక్క కుక్క కరచి బాధదేయు | |
బలిమి లేన్నివేళ బం౦తంబు చెల్లదు | |
విశ్వదాభిరామ విసురావేమ | |
అడవికి మృగరాజు అయిన సింహం చిక్కిపోయి ఉంటే | |
వీదిన పోయే బక్క కుక్క కూడ బాధపెడుతుంది | |
అందుకే తగిన బలము లేనిచోట పొరుషము ప్రదర్శించరాదు. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import codecs | |
import pyocr | |
import pyocr.builders | |
from PIL import Image | |
tool = pyocr.get_available_tools()[0] | |
builder = pyocr.builders.TextBuilder() | |
filename ='test_padyam.png' | |
outputfile = "toto.txt" | |
language="tel" | |
txt = tool.image_to_string( | |
Image.open(filename), | |
lang=language, | |
builder=builder | |
) | |
# txt is a Python string | |
with codecs.open(outputfile, 'w', encoding='utf-8') as file_descriptor: | |
builder.write_file(file_descriptor, txt) | |
# toto.txt is a simple text file, encoded in utf-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://pasteboard.co/bAVR37ACqsBw.png |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment