updated En to Ur translation API
Browse files
app.py
CHANGED
@@ -53,20 +53,19 @@ def translate(target, text):
|
|
53 |
Returns:
|
54 |
res (string): Translated text.
|
55 |
'''
|
56 |
-
url = "https://
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
payload = [{ "Text": text }]
|
61 |
headers = {
|
62 |
-
"x-rapidapi-key":
|
63 |
-
"x-rapidapi-host": "
|
64 |
"Content-Type": "application/json"
|
65 |
}
|
66 |
|
67 |
-
response = requests.post(url, json=payload, headers=headers
|
68 |
res = response.json()
|
69 |
-
|
|
|
70 |
|
71 |
|
72 |
def infer(user_input: str):
|
|
|
53 |
Returns:
|
54 |
res (string): Translated text.
|
55 |
'''
|
56 |
+
url = "https://google-api31.p.rapidapi.com/translate"
|
57 |
|
58 |
+
payload = { "text": text, "to": target, "from_lang": "" }
|
|
|
|
|
59 |
headers = {
|
60 |
+
"x-rapidapi-key": "0875969c18mshea4b5d106303222p197cb2jsnd47e91b7da30",
|
61 |
+
"x-rapidapi-host": "google-api31.p.rapidapi.com",
|
62 |
"Content-Type": "application/json"
|
63 |
}
|
64 |
|
65 |
+
response = requests.post(url, json=payload, headers=headers)
|
66 |
res = response.json()
|
67 |
+
|
68 |
+
return res[0]["translated"]
|
69 |
|
70 |
|
71 |
def infer(user_input: str):
|