Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -340,7 +340,7 @@ def transcribe_video_with_speakers(video_path):
|
|
| 340 |
|
| 341 |
# return translated_json
|
| 342 |
|
| 343 |
-
def update_translations(file, edited_table, process_mode):
|
| 344 |
"""
|
| 345 |
Update the translations based on user edits in the Gradio Dataframe.
|
| 346 |
"""
|
|
@@ -364,9 +364,11 @@ def update_translations(file, edited_table, process_mode):
|
|
| 364 |
}
|
| 365 |
for _, row in edited_table.iterrows()
|
| 366 |
]
|
|
|
|
|
|
|
| 367 |
|
| 368 |
# Call the function to process the video with updated translations
|
| 369 |
-
add_transcript_voiceover(file.name,
|
| 370 |
|
| 371 |
# Calculate elapsed time
|
| 372 |
elapsed_time = time.time() - start_time
|
|
@@ -1309,7 +1311,7 @@ def upload_and_manage(file, target_language, process_mode):
|
|
| 1309 |
elapsed_time_display = f"Processing completed in {elapsed_time:.2f} seconds."
|
| 1310 |
logger.info(f"Processing completed in {elapsed_time:.2f} seconds.")
|
| 1311 |
|
| 1312 |
-
return editable_table, output_video_path, elapsed_time_display
|
| 1313 |
|
| 1314 |
except Exception as e:
|
| 1315 |
logger.error(f"An error occurred: {str(e)}")
|
|
@@ -1322,8 +1324,13 @@ def build_interface():
|
|
| 1322 |
with gr.Row():
|
| 1323 |
with gr.Column(scale=4):
|
| 1324 |
file_input = gr.File(label="Upload Video/Audio File")
|
| 1325 |
-
language_input = gr.Dropdown(["en", "es", "fr", "zh"], label="Select Language")
|
| 1326 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1327 |
submit_button = gr.Button("Post and Process")
|
| 1328 |
|
| 1329 |
with gr.Column(scale=8):
|
|
@@ -1364,14 +1371,14 @@ def build_interface():
|
|
| 1364 |
|
| 1365 |
save_changes_button.click(
|
| 1366 |
update_translations,
|
| 1367 |
-
inputs=[file_input, editable_table, process_mode],
|
| 1368 |
outputs=[processed_video_output, elapsed_time_display]
|
| 1369 |
)
|
| 1370 |
|
| 1371 |
submit_button.click(
|
| 1372 |
upload_and_manage,
|
| 1373 |
inputs=[file_input, language_input, process_mode],
|
| 1374 |
-
outputs=[editable_table, processed_video_output, elapsed_time_display]
|
| 1375 |
)
|
| 1376 |
|
| 1377 |
# Connect submit button to save_feedback_db function
|
|
|
|
| 340 |
|
| 341 |
# return translated_json
|
| 342 |
|
| 343 |
+
def update_translations(file, edited_table, source_language, target_language, process_mode):
|
| 344 |
"""
|
| 345 |
Update the translations based on user edits in the Gradio Dataframe.
|
| 346 |
"""
|
|
|
|
| 364 |
}
|
| 365 |
for _, row in edited_table.iterrows()
|
| 366 |
]
|
| 367 |
+
|
| 368 |
+
translated_json = apply_adaptive_speed(updated_translations, source_language, target_language)
|
| 369 |
|
| 370 |
# Call the function to process the video with updated translations
|
| 371 |
+
add_transcript_voiceover(file.name, translated_json, output_video_path, process_mode)
|
| 372 |
|
| 373 |
# Calculate elapsed time
|
| 374 |
elapsed_time = time.time() - start_time
|
|
|
|
| 1311 |
elapsed_time_display = f"Processing completed in {elapsed_time:.2f} seconds."
|
| 1312 |
logger.info(f"Processing completed in {elapsed_time:.2f} seconds.")
|
| 1313 |
|
| 1314 |
+
return source_language, editable_table, output_video_path, elapsed_time_display
|
| 1315 |
|
| 1316 |
except Exception as e:
|
| 1317 |
logger.error(f"An error occurred: {str(e)}")
|
|
|
|
| 1324 |
with gr.Row():
|
| 1325 |
with gr.Column(scale=4):
|
| 1326 |
file_input = gr.File(label="Upload Video/Audio File")
|
| 1327 |
+
language_input = gr.Dropdown(["en", "es", "fr", "zh"], label="Select Language")
|
| 1328 |
+
source_language_display = gr.Textbox(label="Detected Source Language", interactive=False)
|
| 1329 |
+
process_mode = gr.Radio(
|
| 1330 |
+
choices=[("Transcription Only", 1), ("Transcription with Premium Voice", 2), ("Transcription with Voice Clone", 3)],
|
| 1331 |
+
label="Choose Processing Type",
|
| 1332 |
+
value=1
|
| 1333 |
+
)
|
| 1334 |
submit_button = gr.Button("Post and Process")
|
| 1335 |
|
| 1336 |
with gr.Column(scale=8):
|
|
|
|
| 1371 |
|
| 1372 |
save_changes_button.click(
|
| 1373 |
update_translations,
|
| 1374 |
+
inputs=[file_input, editable_table, source_language_display, language_input, process_mode],
|
| 1375 |
outputs=[processed_video_output, elapsed_time_display]
|
| 1376 |
)
|
| 1377 |
|
| 1378 |
submit_button.click(
|
| 1379 |
upload_and_manage,
|
| 1380 |
inputs=[file_input, language_input, process_mode],
|
| 1381 |
+
outputs=[source_language_display, editable_table, processed_video_output, elapsed_time_display]
|
| 1382 |
)
|
| 1383 |
|
| 1384 |
# Connect submit button to save_feedback_db function
|