ashourzadeh7
commited on
Commit
•
b220179
1
Parent(s):
cefb4b4
Update app.py
Browse files
app.py
CHANGED
@@ -61,15 +61,29 @@ def file_translate(sorce_file_path, pred_file_path):
|
|
61 |
output_file.write(translation + "\n")
|
62 |
return pred_file_path
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
if __name__ == '__main__':
|
65 |
print('\tinit models')
|
66 |
|
67 |
-
global model_dict
|
68 |
|
69 |
-
model_dict = load_models()
|
70 |
|
71 |
interface = gr.Interface(
|
72 |
-
fn=
|
73 |
inputs=[
|
74 |
gr.components.File(label="Input File"),
|
75 |
gr.components.Textbox(label="Output File Name (optional)"),
|
|
|
61 |
output_file.write(translation + "\n")
|
62 |
return pred_file_path
|
63 |
|
64 |
+
def add_line(input_path, output_path):
|
65 |
+
# خواندن محتوای فایل ورودی
|
66 |
+
with open(input_path, encoding="utf-8") as f:
|
67 |
+
text = f.read()
|
68 |
+
|
69 |
+
# اضافه کردن خط "سلام" به انتهای متن
|
70 |
+
new_text = text + "\nسلام"
|
71 |
+
|
72 |
+
# نوشتن متن جدید در فایل خروجی
|
73 |
+
with open(output_path, "w", encoding="utf-8") as f:
|
74 |
+
f.write(new_text)
|
75 |
+
|
76 |
+
return output_path
|
77 |
+
|
78 |
if __name__ == '__main__':
|
79 |
print('\tinit models')
|
80 |
|
81 |
+
#global model_dict
|
82 |
|
83 |
+
#model_dict = load_models()
|
84 |
|
85 |
interface = gr.Interface(
|
86 |
+
fn=add_line,
|
87 |
inputs=[
|
88 |
gr.components.File(label="Input File"),
|
89 |
gr.components.Textbox(label="Output File Name (optional)"),
|