Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -39,7 +39,8 @@ def translate_srt(input_file, source_language_code, target_language_code):
|
|
39 |
subs = pysrt.open(input_file)
|
40 |
total_subs = len(subs)
|
41 |
translated_subs = []
|
42 |
-
|
|
|
43 |
|
44 |
for idx, sub in enumerate(subs):
|
45 |
translated_text = translate_text(sub.text, source_language_code, target_language_code)
|
@@ -51,7 +52,7 @@ def translate_srt(input_file, source_language_code, target_language_code):
|
|
51 |
progress_bar.empty() # Optionally clear the progress bar after completion
|
52 |
return translated_file
|
53 |
|
54 |
-
st.title("SRT
|
55 |
st.write("We use model from [Language Technology Research Group at the University of Helsinki](https://huggingface.co/Helsinki-NLP). For API use please visit [this space](https://huggingface.co/spaces/Lenylvt/SRT_Translation-API)")
|
56 |
|
57 |
# Fetch language options
|
@@ -71,13 +72,13 @@ if file_input is not None and source_language_code and target_language_code:
|
|
71 |
temp_file.write(file_input.getvalue())
|
72 |
temp_file_path = temp_file.name
|
73 |
|
74 |
-
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
|
82 |
st.download_button(
|
83 |
label="⬇️ Download Translated SRT",
|
|
|
39 |
subs = pysrt.open(input_file)
|
40 |
total_subs = len(subs)
|
41 |
translated_subs = []
|
42 |
+
progress_text = "Operation in progress. For information, the progress bar start when the translation begin."
|
43 |
+
progress_bar = st.progress(0, text=progress_text) # Initialize the progress bar
|
44 |
|
45 |
for idx, sub in enumerate(subs):
|
46 |
translated_text = translate_text(sub.text, source_language_code, target_language_code)
|
|
|
52 |
progress_bar.empty() # Optionally clear the progress bar after completion
|
53 |
return translated_file
|
54 |
|
55 |
+
st.title("SRT Translation")
|
56 |
st.write("We use model from [Language Technology Research Group at the University of Helsinki](https://huggingface.co/Helsinki-NLP). For API use please visit [this space](https://huggingface.co/spaces/Lenylvt/SRT_Translation-API)")
|
57 |
|
58 |
# Fetch language options
|
|
|
72 |
temp_file.write(file_input.getvalue())
|
73 |
temp_file_path = temp_file.name
|
74 |
|
75 |
+
translated_srt = translate_srt(temp_file_path, source_language_code, target_language_code)
|
76 |
|
77 |
+
buffer = BytesIO()
|
78 |
+
translated_srt.save(buffer, encoding='utf-8')
|
79 |
+
buffer.seek(0)
|
80 |
+
|
81 |
+
translated_srt_bytes = buffer.getvalue()
|
82 |
|
83 |
st.download_button(
|
84 |
label="⬇️ Download Translated SRT",
|