Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,8 +5,9 @@ from transformers import pipeline
|
|
| 5 |
pipe = pipeline("translation", model="chi-vi/hirashiba-mt-tiny-zh-vi")
|
| 6 |
|
| 7 |
def translate_text(input_text):
|
| 8 |
-
|
| 9 |
-
|
|
|
|
| 10 |
|
| 11 |
if __name__ == '__main__':
|
| 12 |
with gr.Blocks() as app:
|
|
|
|
| 5 |
pipe = pipeline("translation", model="chi-vi/hirashiba-mt-tiny-zh-vi")
|
| 6 |
|
| 7 |
def translate_text(input_text):
|
| 8 |
+
lines = input_text.split('\n') # Tách từng dòng
|
| 9 |
+
translated_lines = [pipe(line, max_length=512)[0]['translation_text'] if line.strip() else '' for line in lines]
|
| 10 |
+
return '\n'.join(translated_lines) # Gộp lại với xuống dòng
|
| 11 |
|
| 12 |
if __name__ == '__main__':
|
| 13 |
with gr.Blocks() as app:
|