Spaces:
Sleeping
Sleeping
import os | |
from paddleocr import PaddleOCR | |
import translate_speak | |
def ocr_with_paddle(img): | |
""" | |
Paddle OCR | |
""" | |
try: | |
finaltext = '' | |
ocr = PaddleOCR(lang='en', use_angle_cls=True) | |
result = ocr.ocr(img) | |
if result[0] == None: | |
finaltext = "Text not found in the given Image. Try with another Image" | |
else: | |
for i in range(len(result[0])): | |
text = result[0][i][1][0] | |
finaltext += ' ' + text | |
audio_path = translate_speak.audio_streaming(txt=finaltext, to=1) | |
return finaltext, audio_path | |
except Exception as e: | |
return f"An error occurred. Please upload image {e}", translate_speak.audio_streaming(txt="An error occurred. Please upload image", to=1) | |
if __name__ == "__main__": | |
print(ocr_with_paddle('Images/download.jpeg')) |