Spaces:
Build error
Build error
fixing the process app
Browse files
app.py
CHANGED
@@ -3,8 +3,8 @@ from translator import ServerTranslator
|
|
3 |
import json
|
4 |
|
5 |
|
6 |
-
def clear_all(input_json, input_text, input_dest_lang,
|
7 |
-
return None, "", "", ""
|
8 |
|
9 |
|
10 |
def translate_text_json(input_json):
|
@@ -34,31 +34,41 @@ def translate_text_text(input_text, input_dest_lang):
|
|
34 |
|
35 |
|
36 |
with gr.Blocks() as demo:
|
37 |
-
input_json = gr.components.File(label="Upload JSON file")
|
38 |
-
input_dest_lang = gr.components.Textbox(placeholder='Example input: vi',label="Destination Language")
|
39 |
-
input_text = gr.components.Textbox(placeholder='Example inputs: I love you, I love you than myself', label="Enter Text")
|
40 |
-
translated_text = gr.components.Textbox(placeholder='Example outputs: Anh yêu em, Anh yêu em hơn bản thân mình',
|
41 |
-
|
42 |
|
43 |
with gr.Column():
|
|
|
|
|
|
|
|
|
44 |
submit_json = gr.Button("Submit Json")
|
45 |
-
submit_text = gr.Button("Submit Text")
|
46 |
submit_json.click(
|
47 |
translate_text_json,
|
48 |
[input_json], # Pass all three inputs
|
49 |
-
[
|
50 |
)
|
51 |
with gr.Column():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
submit_text.click(
|
53 |
translate_text_text,
|
54 |
[input_text, input_dest_lang], # Pass all three inputs
|
55 |
-
[
|
56 |
)
|
57 |
clear = gr.Button("Clear")
|
58 |
clear.click(
|
59 |
clear_all,
|
60 |
-
[input_json, input_text, input_dest_lang,
|
61 |
-
[input_json, input_text, input_dest_lang,
|
62 |
)
|
63 |
|
64 |
demo.launch(share=True)
|
|
|
3 |
import json
|
4 |
|
5 |
|
6 |
+
def clear_all(input_json, input_text, input_dest_lang, translated_text_json, translted_text_text):
|
7 |
+
return None, "", "", "", ""
|
8 |
|
9 |
|
10 |
def translate_text_json(input_json):
|
|
|
34 |
|
35 |
|
36 |
with gr.Blocks() as demo:
|
37 |
+
# input_json = gr.components.File(label="Upload JSON file")
|
38 |
+
# input_dest_lang = gr.components.Textbox(placeholder='Example input: vi',label="Destination Language")
|
39 |
+
# input_text = gr.components.Textbox(placeholder='Example inputs: I love you, I love you than myself', label="Enter Text")
|
40 |
+
# translated_text = gr.components.Textbox(placeholder='Example outputs: Anh yêu em, Anh yêu em hơn bản thân mình',
|
41 |
+
# label="Translated Text")
|
42 |
|
43 |
with gr.Column():
|
44 |
+
translated_text_json = gr.Textbox(placeholder='Example outputs: Anh yêu em, Anh yêu em hơn bản thân mình',
|
45 |
+
label="Translated Text for JSON file")
|
46 |
+
input_json = gr.components.File(label="Upload JSON file")
|
47 |
+
|
48 |
submit_json = gr.Button("Submit Json")
|
|
|
49 |
submit_json.click(
|
50 |
translate_text_json,
|
51 |
[input_json], # Pass all three inputs
|
52 |
+
[translated_text_json]
|
53 |
)
|
54 |
with gr.Column():
|
55 |
+
translated_text_text = gr.Textbox(
|
56 |
+
placeholder='Example outputs: Anh yêu em, Anh yêu em hơn bản thân mình',
|
57 |
+
label="Translated Text for Input Text and Dest Lang")
|
58 |
+
input_dest_lang = gr.components.Textbox(placeholder='Example input: vi', label="Destination Language")
|
59 |
+
input_text = gr.components.Textbox(placeholder='Example inputs: I love you, I love you than myself',
|
60 |
+
label="Enter Text")
|
61 |
+
submit_text = gr.Button("Submit Text")
|
62 |
submit_text.click(
|
63 |
translate_text_text,
|
64 |
[input_text, input_dest_lang], # Pass all three inputs
|
65 |
+
[translated_text_text]
|
66 |
)
|
67 |
clear = gr.Button("Clear")
|
68 |
clear.click(
|
69 |
clear_all,
|
70 |
+
[input_json, input_text, input_dest_lang, translated_text_json, translated_text_text],
|
71 |
+
[input_json, input_text, input_dest_lang, translated_text_json, translated_text_text]
|
72 |
)
|
73 |
|
74 |
demo.launch(share=True)
|