ashourzadeh7 commited on
Commit
02bf3e1
1 Parent(s): e8fbcb6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -23,7 +23,7 @@ def translate(text, src_lang, tgt_lang):
23
  result = translation_pipeline(text)
24
  return result[0]['translation_text']
25
 
26
- def file_translate(sorce_file_path, pred_file_path):
27
  sorce_list = []
28
  with open(sorce_file_path, "r", encoding="utf-8") as sorce_file:
29
  for line in sorce_file:
@@ -31,7 +31,7 @@ def file_translate(sorce_file_path, pred_file_path):
31
 
32
  pred_list = []
33
  for line in sorce_list:
34
- pred_list.append(translate(line, list(langs_dict.keys())[0], list(langs_dict.keys())[1]))
35
 
36
  with open(pred_file_path, "w", encoding="utf-8") as output_file:
37
  for translation in pred_list:
@@ -58,6 +58,8 @@ if __name__ == '__main__':
58
  fn=file_translate,
59
  inputs=[
60
  gr.components.File(label="Input File"),
 
 
61
  gr.components.Textbox(label="Output File Name (optional)"),
62
  ],
63
  outputs=[
 
23
  result = translation_pipeline(text)
24
  return result[0]['translation_text']
25
 
26
+ def file_translate(sorce_file_path, src_lang, tgt_lang, pred_file_path):
27
  sorce_list = []
28
  with open(sorce_file_path, "r", encoding="utf-8") as sorce_file:
29
  for line in sorce_file:
 
31
 
32
  pred_list = []
33
  for line in sorce_list:
34
+ pred_list.append(translate(line, src_lang, tgt_lang))
35
 
36
  with open(pred_file_path, "w", encoding="utf-8") as output_file:
37
  for translation in pred_list:
 
58
  fn=file_translate,
59
  inputs=[
60
  gr.components.File(label="Input File"),
61
+ gr.components.Dropdown(label="زبان مبدا", choices=list(langs_dict.keys())),
62
+ gr.components.Dropdown(label="زبان مقصد", choices=list(langs_dict.keys())),
63
  gr.components.Textbox(label="Output File Name (optional)"),
64
  ],
65
  outputs=[