'Google Cloud Vision API error "Invalid language hints."

I am using vision api to extract text (document_text_detection) in my project for last two year and never faced this issue. Since yesterday the api is randomly responding with the error :

{ code: 3 message: "Invalid language hints." }

for the same image. I experimented with bunch of images, sometimes the api extracts text fine and sometimes throws "Invalid language hints" error for a same image.

I have tried updating vision api library from v1 to v2, sending language hints as 'en' still the same issue persist. I have looked into the Google documentation and checked StackOverFlow as well but unable to find any solution.

from google.cloud import vision
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = google_cred_file


vision_client = vision.ImageAnnotatorClient()
file = open(file_path,"rb")
image = vision.Image(content=file.read())

api_resp = vision_client.document_text_detection(image=image)
if api_resp.error.message:
    log.error(api_resp)


Solution 1:[1]

@Manoj kumar - I tried to run code on my system with your image , I made change in one line and it executed successfully. Please find below.

enter image description here

Solution 2:[2]

I am part of Google Cloud Platform Support and the issue with Cloud Vision has been resolved for all affected users as of Monday, 2022-05-16 10:00 US/Pacific.

The issue is also removed from the Google Cloud Service Health page.

You may now try the Detect text Vision API Quickstart or try your own code.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vishal Bulbule
Solution 2 Scott B