Spaces:
Sleeping
Sleeping
| def ocr_tool(image_path: str) -> str: | |
| """Extracts text from images or scanned documents using OCR. | |
| Args: | |
| image_path: Path to the image file | |
| """ | |
| try: | |
| ocr_engine = PaddleOCR(use_angle_cls=True, lang='en') | |
| result = ocr_engine.ocr(image_path, cls=True) | |
| texts = [line[1][0] for line in result[0]] if result else [] | |
| return "\n".join(texts) | |
| except Exception as e: | |
| return f"OCR Error: {str(e)}" | |