Google's RomanizeText API is broken

35 views
Skip to first unread message

RAJDEEP PAL

unread,
May 23, 2023, 10:03:17 AM5/23/23
to Google APIs Discovery Service Users
Hello,

We need the Romanization feature badly. Someone, please help.

As per the Romanize text docs, I wrote the following Python code to transliterate from some language script to Roman script.

    # Authenticate using credentials.
    import os
    os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "translate.json"
    PROJECT_ID = "project-id"
    LOCATION = "global"

    # Imports the Google Cloud Translation library
    from google.cloud import translate_v3

    # Transliteration.
    def romanize_text(text, src_lang="hi", tgt_lang="en"):

        client = translate_v3.TranslationServiceClient()
        parent = f"projects/{PROJECT_ID}/locations/{LOCATION}"

        response = client.romanize_text(
            request={
                "parent": parent,
                "contents": [text],
                "source_language_code": src_lang,
                "target_language_code": tgt_lang,
            }
        )

        # Display the romanized for each input text provided
        for romanization in response.romanizations:
            print(f"Romanized text: {romanization.romanized_text}")

    romanize_text('यज्ञ का अंतिम लक्ष्य क्या है')

Running the above code, gives the following error:

AttributeError: 'TranslationServiceClient' object has no attribute 'romanize_text'

Also, in the API reference of romanizeText, the right-hand side API Explorer is broken. Whereas, if you select any other method from the left-hand side - its API Explorer works correctly.

We need the Romanization feature badly. Someone, please help.

Thank you,
Rajdeep
Reply all
Reply to author
Forward
0 new messages