Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -36,6 +36,7 @@ def get_alternate_text(text, language):
|
|
36 |
print(e)
|
37 |
response = requests.post(ENDPOINT, data=json.dumps(payload), headers=headers)
|
38 |
retries += 1
|
|
|
39 |
continue
|
40 |
if resp_text is None:
|
41 |
return "Error. Please refresh and try", None
|
@@ -43,19 +44,19 @@ def get_alternate_text(text, language):
|
|
43 |
counts = list(map(lambda x: len(x.split()), texts))
|
44 |
return len(text.split()), {"data": list(zip(texts, counts)), "headers": ["Alternatives", "Word Count"]}
|
45 |
|
46 |
-
language = gr.Dropdown(LANGUAGES, value="Spanish", label="Language")
|
47 |
-
text = gr.Textbox(lines=4, label="Text")
|
48 |
-
dataframe = gr.Dataframe(wrap=True)
|
49 |
-
word_count = gr.Textbox(lines=1, label="Word Count")
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
)
|
|
|
|
|
|
|
|
|
57 |
|
58 |
if __name__=="__main__":
|
59 |
-
|
60 |
auth=(os.environ.get('AUTH_USERNAME'), os.environ.get('AUTH_PASSWORD'))
|
61 |
)
|
|
|
36 |
print(e)
|
37 |
response = requests.post(ENDPOINT, data=json.dumps(payload), headers=headers)
|
38 |
retries += 1
|
39 |
+
resp_text = None
|
40 |
continue
|
41 |
if resp_text is None:
|
42 |
return "Error. Please refresh and try", None
|
|
|
44 |
counts = list(map(lambda x: len(x.split()), texts))
|
45 |
return len(text.split()), {"data": list(zip(texts, counts)), "headers": ["Alternatives", "Word Count"]}
|
46 |
|
|
|
|
|
|
|
|
|
47 |
|
48 |
+
with gr.Blocks() as demo:
|
49 |
+
gr.Markdown("# Deepsync Text Rephraser")
|
50 |
+
language = gr.Dropdown(LANGUAGES, value="Spanish", label="Language")
|
51 |
+
text = gr.Textbox(lines=4, label="Text")
|
52 |
+
submit = gr.Button(label="Submit")
|
53 |
+
dataframe = gr.Dataframe(wrap=True)
|
54 |
+
word_count = gr.Textbox(lines=1, label="Word Count")
|
55 |
+
|
56 |
+
submit.click(get_alternate_text, [text, language], [word_count, dataframe])
|
57 |
+
|
58 |
|
59 |
if __name__=="__main__":
|
60 |
+
demo.launch(
|
61 |
auth=(os.environ.get('AUTH_USERNAME'), os.environ.get('AUTH_PASSWORD'))
|
62 |
)
|