Spaces:
Runtime error
Runtime error
seawolf2357
commited on
Commit
•
9063441
1
Parent(s):
63d0c61
initial commit
Browse files
app.py
CHANGED
@@ -1,9 +1,31 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from googletrans import Translator
|
2 |
import gradio as gr
|
3 |
+
import requests
|
4 |
+
|
5 |
+
url = "https://api.edenai.run/v2/text/sentiment_analysis"
|
6 |
+
|
7 |
+
payload = {
|
8 |
+
"response_as_dict": True,
|
9 |
+
"attributes_as_list": False,
|
10 |
+
"show_original_response": False,
|
11 |
+
"providers": "google",
|
12 |
+
"text": inp_text,
|
13 |
+
"language": "ko"
|
14 |
+
}
|
15 |
+
headers = {
|
16 |
+
"accept": "application/json",
|
17 |
+
"content-type": "application/json",
|
18 |
+
"authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiMWI0NzY4YzMtNmM0NC00NThiLTkyMjctNDFhMDVjZDlkZTMxIiwidHlwZSI6ImFwaV90b2tlbiJ9.6nsuq67zZlBXqpH0VUNud64Ii54ETQay0Antfslpsqg"
|
19 |
+
}
|
20 |
+
|
21 |
+
response = requests.post(url, json=payload, headers=headers)
|
22 |
+
|
23 |
+
print(response.text)
|
24 |
+
|
25 |
+
|
26 |
+
inp_text = gr.inputs.Textbox(label='Input')
|
27 |
+
response.text = gr.outputs.Textbox(label='Output')
|
28 |
+
|
29 |
+
gr.Interface(fn=translation, inputs=inp_text, outputs=response.text, title='Translation',theme='peach').launch(enable_queue=True)
|
30 |
+
|
31 |
+
|