updates for dropdown list
Browse files
app.py
CHANGED
@@ -77,6 +77,10 @@ class myTheme(Base):
|
|
77 |
)
|
78 |
|
79 |
|
|
|
|
|
|
|
|
|
80 |
def detect_lang(article):
|
81 |
"""
|
82 |
Language Detection using library langid
|
@@ -135,8 +139,8 @@ with gr.Blocks(theme=myTheme) as demo:
|
|
135 |
lang_select = gr.Radio(["English", "Chinese"], label="Select Desired Language")
|
136 |
result = gr.Textbox(label="Translated Result")
|
137 |
trans_btn = gr.Button("Translate")
|
138 |
-
if toolkit_select.select
|
139 |
trans_btn.click(fn=opus_trans, inputs=[article, lang_select], outputs=result)
|
140 |
-
elif toolkit_select.select
|
141 |
trans_btn.click(fn=opus_trans, inputs=[article, lang_select], outputs=result)
|
142 |
demo.launch()
|
|
|
77 |
)
|
78 |
|
79 |
|
80 |
+
def on_select(evt: gr.SelectData): # SelectData is a subclass of EventData
|
81 |
+
return evt.value
|
82 |
+
|
83 |
+
|
84 |
def detect_lang(article):
|
85 |
"""
|
86 |
Language Detection using library langid
|
|
|
139 |
lang_select = gr.Radio(["English", "Chinese"], label="Select Desired Language")
|
140 |
result = gr.Textbox(label="Translated Result")
|
141 |
trans_btn = gr.Button("Translate")
|
142 |
+
if toolkit_select.select(on_select, None, toolkit_select):
|
143 |
trans_btn.click(fn=opus_trans, inputs=[article, lang_select], outputs=result)
|
144 |
+
elif toolkit_select.select(on_select, None, toolkit_select):
|
145 |
trans_btn.click(fn=opus_trans, inputs=[article, lang_select], outputs=result)
|
146 |
demo.launch()
|