Update app.py
Browse files
app.py
CHANGED
@@ -170,41 +170,30 @@ import json
|
|
170 |
|
171 |
def update_translations(file, edited_table):
|
172 |
"""
|
173 |
-
Update translations
|
174 |
-
|
175 |
-
Parameters:
|
176 |
-
file: Uploaded video file object.
|
177 |
-
edited_table: Updated translations from the Gradio editable table (list of dictionaries).
|
178 |
-
|
179 |
-
Returns:
|
180 |
-
output_video_path: The path to the video with updated translations.
|
181 |
"""
|
182 |
output_video_path = "output_video.mp4"
|
183 |
|
184 |
try:
|
185 |
-
#
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
# Call the function to add subtitles to the video
|
201 |
-
add_transcript_to_video(file.name, edited_table, output_video_path)
|
202 |
|
203 |
except Exception as e:
|
204 |
raise ValueError(f"Error updating translations: {e}")
|
205 |
|
206 |
-
return output_video_path
|
207 |
-
|
208 |
# Core functionalities
|
209 |
def upload_and_manage(file, language):
|
210 |
if file is None:
|
|
|
170 |
|
171 |
def update_translations(file, edited_table):
|
172 |
"""
|
173 |
+
Update the translations based on user edits in the Gradio Dataframe.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
"""
|
175 |
output_video_path = "output_video.mp4"
|
176 |
|
177 |
try:
|
178 |
+
# Convert the edited_table (list of lists) back to list of dictionaries
|
179 |
+
updated_translations = [
|
180 |
+
{
|
181 |
+
"start": row[0], # First column
|
182 |
+
"original": row[1], # Second column
|
183 |
+
"translated": row[2], # Third column
|
184 |
+
"end": row[3], # Fourth column
|
185 |
+
}
|
186 |
+
for row in edited_table
|
187 |
+
]
|
188 |
+
|
189 |
+
# Call the function to process the video with updated translations
|
190 |
+
add_transcript_to_video(file.name, updated_translations, output_video_path)
|
191 |
+
|
192 |
+
return output_video_path
|
|
|
|
|
193 |
|
194 |
except Exception as e:
|
195 |
raise ValueError(f"Error updating translations: {e}")
|
196 |
|
|
|
|
|
197 |
# Core functionalities
|
198 |
def upload_and_manage(file, language):
|
199 |
if file is None:
|