We need the Romanization feature badly. Can someone please help? We want to transliterate (not translate) from Hindi (Devanagari script) language to English (Roman script) language.
Input
romanize_text('अंतिम लक्ष्य क्या है')
Expected Output
'antim lakshya kya hai'
Environment details
- OS type and version: Windows 11
- Python version:
3.9.11
- pip version:
23.1.2
google-cloud-translate version: 3.11.1
Things I tried
- Complained at Google APIs groups.
- Looked up in the Google's API reference of romanizeText. I saw that 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.
- Looked into the source code file but couldn't find any API named
romanize_text.
Steps to reproduce
- As per the Google Romanize text docs, I wrote the following Python code to transliterate from some language script to Roman script.
- The below code with minor replacements works correctly for
translate_text API.
Code example
# 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('अंतिम लक्ष्य क्या है')
Stack trace
AttributeError: 'TranslationServiceClient' object has no attribute 'romanize_text'
We need the Romanization feature urgently. Can someone please help?
We need the Romanization feature badly. Can someone please help? We want to transliterate (not translate) from Hindi (Devanagari script) language to English (Roman script) language.
Input
romanize_text('अंतिम लक्ष्य क्या है')Expected Output
'antim lakshya kya hai'Environment details
3.9.1123.1.2google-cloud-translateversion:3.11.1Things I tried
romanize_text.Steps to reproduce
translate_textAPI.Code example
Stack trace
We need the Romanization feature urgently. Can someone please help?