Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -517,12 +517,15 @@ def update_translations(file, edited_table, process_mode):
|
|
517 |
elapsed_time = time.time() - start_time
|
518 |
elapsed_time_display = f"Updates applied successfully in {elapsed_time:.2f} seconds."
|
519 |
|
|
|
|
|
|
|
520 |
# Return the path to the updated JSON file as well
|
521 |
return output_video_path, updated_json_path, elapsed_time_display
|
522 |
except Exception as e:
|
523 |
logger.error(f"Error updating translations: {e}")
|
524 |
# Return Nones for all outputs if an error occurs
|
525 |
-
return None,
|
526 |
|
527 |
def create_subtitle_clip_pil(text, start_time, end_time, video_width, video_height, font_path):
|
528 |
try:
|
@@ -1334,11 +1337,19 @@ def upload_and_manage(file, target_language, process_mode):
|
|
1334 |
elapsed_time_display = f"Processing completed in {elapsed_time:.2f} seconds."
|
1335 |
logger.info(f"Processing completed in {elapsed_time:.2f} seconds.")
|
1336 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1337 |
return editable_table, output_video_path, translated_json_filepath, elapsed_time_display
|
1338 |
|
1339 |
except Exception as e:
|
1340 |
logger.error(f"An error occurred: {str(e)}")
|
1341 |
-
return [], None,
|
1342 |
|
1343 |
# Gradio Interface with Tabs
|
1344 |
def build_interface():
|
|
|
517 |
elapsed_time = time.time() - start_time
|
518 |
elapsed_time_display = f"Updates applied successfully in {elapsed_time:.2f} seconds."
|
519 |
|
520 |
+
if not os.path.isfile(updated_json_path):
|
521 |
+
logger.error(f"Expected file at {updated_json_path} but got a directory.")
|
522 |
+
return [], None, "", f"Translated JSON path is invalid."
|
523 |
# Return the path to the updated JSON file as well
|
524 |
return output_video_path, updated_json_path, elapsed_time_display
|
525 |
except Exception as e:
|
526 |
logger.error(f"Error updating translations: {e}")
|
527 |
# Return Nones for all outputs if an error occurs
|
528 |
+
return None, updated_json_path, None
|
529 |
|
530 |
def create_subtitle_clip_pil(text, start_time, end_time, video_width, video_height, font_path):
|
531 |
try:
|
|
|
1337 |
elapsed_time_display = f"Processing completed in {elapsed_time:.2f} seconds."
|
1338 |
logger.info(f"Processing completed in {elapsed_time:.2f} seconds.")
|
1339 |
|
1340 |
+
if not os.path.isfile(output_video_path):
|
1341 |
+
logger.error(f"Expected file at {output_video_path} but got a directory.")
|
1342 |
+
return [], None, "", f"Output video path is invalid."
|
1343 |
+
|
1344 |
+
if not os.path.isfile(translated_json_filepath):
|
1345 |
+
logger.error(f"Expected file at {translated_json_filepath} but got a directory.")
|
1346 |
+
return [], None, "", f"Translated JSON path is invalid."
|
1347 |
+
|
1348 |
return editable_table, output_video_path, translated_json_filepath, elapsed_time_display
|
1349 |
|
1350 |
except Exception as e:
|
1351 |
logger.error(f"An error occurred: {str(e)}")
|
1352 |
+
return [], None, translated_json_filepath, f"An error occurred: {str(e)}"
|
1353 |
|
1354 |
# Gradio Interface with Tabs
|
1355 |
def build_interface():
|