Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,7 +38,8 @@ def create_DubIndic_interface():
|
|
| 38 |
return (
|
| 39 |
"Please provide both an audio file and a target language.",
|
| 40 |
None, "", "", None, "",
|
| 41 |
-
gr.update(visible=False), gr.update(visible=False)
|
|
|
|
| 42 |
)
|
| 43 |
try:
|
| 44 |
logger.info("Calling /process_audio_pipeline_step1 with file: %s", audio_file)
|
|
@@ -53,14 +54,16 @@ def create_DubIndic_interface():
|
|
| 53 |
# [status, internal_val, orig_audio, trans, transl, dubbed_audio, progress]
|
| 54 |
return (
|
| 55 |
result[0], result[2], result[3], result[4], result[5], result[6],
|
| 56 |
-
gr.update(visible=True), gr.update(visible=True) # Make edit and merge sections visible
|
|
|
|
| 57 |
)
|
| 58 |
except Exception as e:
|
| 59 |
logger.error("Error in start_processing: %s", e, exc_info=True)
|
| 60 |
return (
|
| 61 |
f"Error starting the process: {e}",
|
| 62 |
None, "", "", None, "",
|
| 63 |
-
gr.update(visible=False), gr.update(visible=False)
|
|
|
|
| 64 |
)
|
| 65 |
|
| 66 |
def navigate_chunk(transcription, translation, direction):
|
|
@@ -77,10 +80,10 @@ def create_DubIndic_interface():
|
|
| 77 |
logger.info("Received result from navigation: %s", result)
|
| 78 |
# API returns a 6-element tuple
|
| 79 |
# [internal_val, orig_audio, trans, transl, dubbed_audio, progress]
|
| 80 |
-
return result[1], result[2], result[3], result[4], result[5]
|
| 81 |
except Exception as e:
|
| 82 |
logger.error("Error navigating chunks: %s", e, exc_info=True)
|
| 83 |
-
return None, f"Error navigating chunks: {e}", "", None, ""
|
| 84 |
|
| 85 |
def generate_dubbed_chunk(transcription, translation):
|
| 86 |
if not transcription and not translation:
|
|
@@ -195,7 +198,8 @@ def create_DubIndic_interface():
|
|
| 195 |
with gr.Row():
|
| 196 |
prev_btn = gr.Button("◀️ Previous")
|
| 197 |
next_btn = gr.Button("Next ▶️")
|
| 198 |
-
original_audio = gr.Audio(label="Original Chunk Audio", type="filepath", interactive=False)
|
|
|
|
| 199 |
transcription_text = gr.Textbox(label="Transcription (edit if needed)", lines=2, interactive=True)
|
| 200 |
translation_text = gr.Textbox(label="Translation (edit if needed)", lines=2, interactive=True)
|
| 201 |
with gr.Row():
|
|
@@ -215,19 +219,19 @@ def create_DubIndic_interface():
|
|
| 215 |
process_btn.click(
|
| 216 |
fn=start_processing,
|
| 217 |
inputs=[audio_input, lang_dropdown],
|
| 218 |
-
outputs=[step1_output, original_audio, transcription_text, translation_text, dubbed_audio, progress_text, edit_section, merge_section]
|
| 219 |
)
|
| 220 |
|
| 221 |
prev_btn.click(
|
| 222 |
fn=lambda t, tr: navigate_chunk(t, tr, "prev"),
|
| 223 |
inputs=[transcription_text, translation_text],
|
| 224 |
-
outputs=[original_audio, transcription_text, translation_text, dubbed_audio, progress_text]
|
| 225 |
)
|
| 226 |
|
| 227 |
next_btn.click(
|
| 228 |
fn=lambda t, tr: navigate_chunk(t, tr, "next"),
|
| 229 |
inputs=[transcription_text, translation_text],
|
| 230 |
-
outputs=[original_audio, transcription_text, translation_text, dubbed_audio, progress_text]
|
| 231 |
)
|
| 232 |
|
| 233 |
generate_btn.click(
|
|
|
|
| 38 |
return (
|
| 39 |
"Please provide both an audio file and a target language.",
|
| 40 |
None, "", "", None, "",
|
| 41 |
+
gr.update(visible=False), gr.update(visible=False),
|
| 42 |
+
None, gr.update(visible=False)
|
| 43 |
)
|
| 44 |
try:
|
| 45 |
logger.info("Calling /process_audio_pipeline_step1 with file: %s", audio_file)
|
|
|
|
| 54 |
# [status, internal_val, orig_audio, trans, transl, dubbed_audio, progress]
|
| 55 |
return (
|
| 56 |
result[0], result[2], result[3], result[4], result[5], result[6],
|
| 57 |
+
gr.update(visible=True), gr.update(visible=True), # Make edit and merge sections visible
|
| 58 |
+
result[2] if result[2] else None, gr.update(visible=True if result[2] else False)
|
| 59 |
)
|
| 60 |
except Exception as e:
|
| 61 |
logger.error("Error in start_processing: %s", e, exc_info=True)
|
| 62 |
return (
|
| 63 |
f"Error starting the process: {e}",
|
| 64 |
None, "", "", None, "",
|
| 65 |
+
gr.update(visible=False), gr.update(visible=False),
|
| 66 |
+
None, gr.update(visible=False)
|
| 67 |
)
|
| 68 |
|
| 69 |
def navigate_chunk(transcription, translation, direction):
|
|
|
|
| 80 |
logger.info("Received result from navigation: %s", result)
|
| 81 |
# API returns a 6-element tuple
|
| 82 |
# [internal_val, orig_audio, trans, transl, dubbed_audio, progress]
|
| 83 |
+
return result[1], result[2], result[3], result[4], result[5], result[1] if result[1] else None
|
| 84 |
except Exception as e:
|
| 85 |
logger.error("Error navigating chunks: %s", e, exc_info=True)
|
| 86 |
+
return None, f"Error navigating chunks: {e}", "", None, "", None
|
| 87 |
|
| 88 |
def generate_dubbed_chunk(transcription, translation):
|
| 89 |
if not transcription and not translation:
|
|
|
|
| 198 |
with gr.Row():
|
| 199 |
prev_btn = gr.Button("◀️ Previous")
|
| 200 |
next_btn = gr.Button("Next ▶️")
|
| 201 |
+
original_audio = gr.Audio(label="🎧 Original Chunk Audio", type="filepath", interactive=False)
|
| 202 |
+
download_original_audio = gr.File(label="💾 Download Original Chunk", visible=False)
|
| 203 |
transcription_text = gr.Textbox(label="Transcription (edit if needed)", lines=2, interactive=True)
|
| 204 |
translation_text = gr.Textbox(label="Translation (edit if needed)", lines=2, interactive=True)
|
| 205 |
with gr.Row():
|
|
|
|
| 219 |
process_btn.click(
|
| 220 |
fn=start_processing,
|
| 221 |
inputs=[audio_input, lang_dropdown],
|
| 222 |
+
outputs=[step1_output, original_audio, transcription_text, translation_text, dubbed_audio, progress_text, edit_section, merge_section, download_original_audio, download_original_audio]
|
| 223 |
)
|
| 224 |
|
| 225 |
prev_btn.click(
|
| 226 |
fn=lambda t, tr: navigate_chunk(t, tr, "prev"),
|
| 227 |
inputs=[transcription_text, translation_text],
|
| 228 |
+
outputs=[original_audio, transcription_text, translation_text, dubbed_audio, progress_text, download_original_audio]
|
| 229 |
)
|
| 230 |
|
| 231 |
next_btn.click(
|
| 232 |
fn=lambda t, tr: navigate_chunk(t, tr, "next"),
|
| 233 |
inputs=[transcription_text, translation_text],
|
| 234 |
+
outputs=[original_audio, transcription_text, translation_text, dubbed_audio, progress_text, download_original_audio]
|
| 235 |
)
|
| 236 |
|
| 237 |
generate_btn.click(
|