Mamadou2727 commited on
Commit
c1f7cbf
1 Parent(s): 7a4282d

Update app

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -17,7 +17,11 @@ def translate(text, candidates: int):
17
 
18
  src = LANG_CODES["French"]
19
  tgt = LANG_CODES["Zarma"]
20
-
 
 
 
 
21
  tokenizer.src_lang = src
22
  tokenizer.tgt_lang = tgt
23
 
@@ -71,10 +75,11 @@ with gr.Blocks() as app:
71
  gr.Markdown(markdown)
72
  with gr.Column():
73
  input_text = gr.components.Textbox(lines=7, label="Input Text", value="")
 
74
  return_seqs = gr.Slider(label="Number of return sequences", value=1, minimum=1, maximum=12, step=1)
75
  outputs = gr.Textbox(lines=7, label="Output Text")
76
 
77
  translate_btn = gr.Button("Traduis!")
78
- translate_btn.click(translate, inputs=[input_text, return_seqs], outputs=outputs)
79
-
80
  app.launch(share=True)
 
17
 
18
  src = LANG_CODES["French"]
19
  tgt = LANG_CODES["Zarma"]
20
+
21
+ # If a file is uploaded, use its content for translation
22
+ if file is not None:
23
+ text = file.read().decode("utf-8")
24
+
25
  tokenizer.src_lang = src
26
  tokenizer.tgt_lang = tgt
27
 
 
75
  gr.Markdown(markdown)
76
  with gr.Column():
77
  input_text = gr.components.Textbox(lines=7, label="Input Text", value="")
78
+ upload_file = gr.File(label="Upload File")
79
  return_seqs = gr.Slider(label="Number of return sequences", value=1, minimum=1, maximum=12, step=1)
80
  outputs = gr.Textbox(lines=7, label="Output Text")
81
 
82
  translate_btn = gr.Button("Traduis!")
83
+ translate_btn.click(translate, inputs=[input_text, upload_file, return_seqs], outputs=outputs)
84
+
85
  app.launch(share=True)