diff --git a/owocr/ocr.py b/owocr/ocr.py index 6af6abd..1fae768 100644 --- a/owocr/ocr.py +++ b/owocr/ocr.py @@ -288,12 +288,14 @@ class GoogleLens: response_dict = response_proto.to_dict(betterproto.Casing.SNAKE) res = '' - text = response_dict['objects_response']['text']['text_layout']['paragraphs'] - for paragraph in text: - for line in paragraph['lines']: - for word in line['words']: - res += word['plain_text'] + word['text_separator'] - res += '\n' + text = response_dict['objects_response']['text'] + if 'text_layout' in text: + paragraphs = text['text_layout']['paragraphs'] + for paragraph in paragraphs: + for line in paragraph['lines']: + for word in line['words']: + res += word['plain_text'] + word['text_separator'] + res += '\n' x = (True, res) return x diff --git a/pyproject.toml b/pyproject.toml index 498f677..a3b883c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "owocr" -version = "1.13.1" +version = "1.13.2" description = "Japanese OCR" readme = "README.md" requires-python = ">=3.11"