Ra-Is commited on
Commit
6dbd92a
1 Parent(s): a2c48e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -15,8 +15,11 @@ def translate(text):
15
  # Make the API request
16
  response = requests.request("POST", url, headers=headers, data=payload)
17
 
18
- # Return the response text
19
- return response.text
 
 
 
20
 
21
  # Create the Gradio interface
22
  demo = gr.Interface(fn=translate, inputs="text", outputs="text")
 
15
  # Make the API request
16
  response = requests.request("POST", url, headers=headers, data=payload)
17
 
18
+ # Parse the response and extract the translation
19
+ response_data = response.json() # Parse the JSON response
20
+ translation = response_data.get("translation", "Translation not found") # Get the translation
21
+
22
+ return translation
23
 
24
  # Create the Gradio interface
25
  demo = gr.Interface(fn=translate, inputs="text", outputs="text")