Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,7 @@ logger = logging.getLogger(__name__)
|
|
| 11 |
# It's recommended to set the HUGGINGFACE_TOKEN as an environment variable
|
| 12 |
token = os.getenv("HUGGINGFACE_TOKEN")
|
| 13 |
|
| 14 |
-
def
|
| 15 |
"""
|
| 16 |
Creates and configures the Gradio interface for the DubIndic application.
|
| 17 |
"""
|
|
@@ -23,22 +23,24 @@ def create_dubindic_interface():
|
|
| 23 |
except Exception as e:
|
| 24 |
logger.error("Error connecting to the private space: %s", e, exc_info=True)
|
| 25 |
# Create a fallback interface to show the connection error
|
| 26 |
-
with gr.Blocks(
|
| 27 |
-
gr.Markdown("#
|
| 28 |
-
gr.
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
| 30 |
return demo
|
| 31 |
|
| 32 |
# Define wrapper functions to call the API endpoints
|
| 33 |
def start_processing(audio_file, target_language):
|
| 34 |
if not audio_file or not target_language:
|
| 35 |
-
gr.Warning("Please provide both an audio file and select a target language.")
|
| 36 |
return (
|
| 37 |
-
"
|
|
|
|
| 38 |
gr.update(visible=False), gr.update(visible=False)
|
| 39 |
)
|
| 40 |
try:
|
| 41 |
-
gr.Info("Starting processing... This may take a moment.")
|
| 42 |
logger.info("Calling /process_audio_pipeline_step1 with file: %s", audio_file)
|
| 43 |
result = client.predict(
|
| 44 |
audio_file=handle_file(audio_file),
|
|
@@ -46,50 +48,54 @@ def create_dubindic_interface():
|
|
| 46 |
api_name="/process_audio_pipeline_step1"
|
| 47 |
)
|
| 48 |
logger.info("Received result from step 1: %s", result)
|
| 49 |
-
|
|
|
|
|
|
|
| 50 |
return (
|
| 51 |
-
|
| 52 |
-
gr.update(visible=True), gr.update(visible=True)
|
| 53 |
)
|
| 54 |
except Exception as e:
|
| 55 |
logger.error("Error in start_processing: %s", e, exc_info=True)
|
| 56 |
-
gr.Error(f"Error starting process: {e}")
|
| 57 |
return (
|
| 58 |
-
f"
|
|
|
|
| 59 |
gr.update(visible=False), gr.update(visible=False)
|
| 60 |
)
|
| 61 |
|
| 62 |
def navigate_chunk(transcription, translation, direction):
|
|
|
|
|
|
|
| 63 |
api_to_call = "/lambda" if direction == "prev" else "/lambda_1"
|
| 64 |
try:
|
| 65 |
logger.info("Calling %s to navigate.", api_to_call)
|
| 66 |
-
result = client.predict(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
logger.info("Received result from navigation: %s", result)
|
|
|
|
|
|
|
| 68 |
return result[1], result[2], result[3], result[4], result[5]
|
| 69 |
except Exception as e:
|
| 70 |
logger.error("Error navigating chunks: %s", e, exc_info=True)
|
| 71 |
-
|
| 72 |
-
# Return gr.update() to avoid changing the component values on error
|
| 73 |
-
return gr.update(), gr.update(), gr.update(), gr.update(), gr.update()
|
| 74 |
|
| 75 |
def generate_dubbed_chunk(transcription, translation):
|
| 76 |
if not transcription and not translation:
|
| 77 |
-
gr.Warning("Cannot generate audio from empty text fields.")
|
| 78 |
return None
|
| 79 |
try:
|
| 80 |
logger.info("Calling /generate_dubbed_chunk.")
|
| 81 |
-
gr.Info("Generating dubbed audio for the current chunk...")
|
| 82 |
dubbed_path = client.predict(
|
| 83 |
transcription=transcription,
|
| 84 |
translation=translation,
|
| 85 |
api_name="/generate_dubbed_chunk"
|
| 86 |
)
|
| 87 |
logger.info("Received dubbed chunk: %s", dubbed_path)
|
| 88 |
-
gr.Info("Dubbed chunk generated successfully!")
|
| 89 |
return dubbed_path
|
| 90 |
except Exception as e:
|
| 91 |
logger.error("Error generating dubbed chunk: %s", e, exc_info=True)
|
| 92 |
-
gr.Error(f"Error generating audio: {e}")
|
| 93 |
return None
|
| 94 |
|
| 95 |
def finalize_current_chunk():
|
|
@@ -97,69 +103,113 @@ def create_dubindic_interface():
|
|
| 97 |
logger.info("Calling /finalize_current_chunk.")
|
| 98 |
progress = client.predict(api_name="/finalize_current_chunk")
|
| 99 |
logger.info("Received finalization progress: %s", progress)
|
| 100 |
-
|
| 101 |
-
return f"β
{progress}"
|
| 102 |
except Exception as e:
|
| 103 |
logger.error("Error finalizing chunk: %s", e, exc_info=True)
|
| 104 |
-
|
| 105 |
-
return f"β Error finalizing: {str(e)}"
|
| 106 |
|
| 107 |
def merge_all_chunks():
|
| 108 |
try:
|
| 109 |
logger.info("Calling /merge_audio_files.")
|
| 110 |
-
gr.Info("Merging all finalized chunks. This may take a moment...")
|
| 111 |
final_status, final_audio = client.predict(api_name="/merge_audio_files")
|
| 112 |
logger.info("Received final merged audio.")
|
| 113 |
-
|
| 114 |
-
return f"π {final_status}", final_audio
|
| 115 |
except Exception as e:
|
| 116 |
logger.error("Error merging audio files: %s", e, exc_info=True)
|
| 117 |
-
|
| 118 |
-
return f"β Merge error: {str(e)}", None
|
| 119 |
-
|
| 120 |
-
# Create custom theme
|
| 121 |
-
custom_theme = gr_themes.Soft(primary_hue="orange", secondary_hue="red", neutral_hue="slate")
|
| 122 |
|
| 123 |
-
#
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
audio_input = gr.Audio(sources=["upload"], type="filepath", label="π΅ Upload Audio File")
|
| 133 |
lang_dropdown = gr.Dropdown(
|
| 134 |
choices=["Assamese", "Bengali", "Gujarati", "Hindi", "Kannada", "Malayalam", "Marathi", "Odia", "Punjabi", "Tamil", "Telugu"],
|
| 135 |
label="π Target Language"
|
| 136 |
)
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
with gr.
|
| 142 |
-
gr.Markdown("### βοΈ Step 2: Edit, Generate & Finalize")
|
| 143 |
with gr.Row():
|
| 144 |
prev_btn = gr.Button("βοΈ Previous")
|
| 145 |
next_btn = gr.Button("Next βΆοΈ")
|
|
|
|
|
|
|
|
|
|
| 146 |
with gr.Row():
|
| 147 |
-
|
| 148 |
-
dubbed_audio = gr.Audio(label="π€ Dubbed Chunk Audio", type="filepath", interactive=False)
|
| 149 |
-
transcription_text = gr.Textbox(label="π Transcription (edit if needed)", lines=3, interactive=True)
|
| 150 |
-
translation_text = gr.Textbox(label="π Translation (edit if needed)", lines=3, interactive=True)
|
| 151 |
-
with gr.Row():
|
| 152 |
-
generate_btn = gr.Button("π Generate Dubbed Chunk", variant="secondary")
|
| 153 |
finalize_btn = gr.Button("βοΈ Finalize Chunk", variant="secondary")
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
with gr.
|
| 158 |
gr.Markdown("### π Step 3: Merge Final Audio")
|
| 159 |
merge_btn = gr.Button("π Merge All Finalized Chunks", variant="primary")
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
|
| 164 |
# Connect functions to UI components
|
| 165 |
process_btn.click(
|
|
@@ -167,41 +217,42 @@ def create_dubindic_interface():
|
|
| 167 |
inputs=[audio_input, lang_dropdown],
|
| 168 |
outputs=[step1_output, original_audio, transcription_text, translation_text, dubbed_audio, progress_text, edit_section, merge_section]
|
| 169 |
)
|
|
|
|
| 170 |
prev_btn.click(
|
| 171 |
fn=lambda t, tr: navigate_chunk(t, tr, "prev"),
|
| 172 |
inputs=[transcription_text, translation_text],
|
| 173 |
outputs=[original_audio, transcription_text, translation_text, dubbed_audio, progress_text]
|
| 174 |
)
|
|
|
|
| 175 |
next_btn.click(
|
| 176 |
fn=lambda t, tr: navigate_chunk(t, tr, "next"),
|
| 177 |
inputs=[transcription_text, translation_text],
|
| 178 |
outputs=[original_audio, transcription_text, translation_text, dubbed_audio, progress_text]
|
| 179 |
)
|
|
|
|
| 180 |
generate_btn.click(
|
| 181 |
fn=generate_dubbed_chunk,
|
| 182 |
inputs=[transcription_text, translation_text],
|
| 183 |
outputs=[dubbed_audio]
|
| 184 |
)
|
|
|
|
| 185 |
finalize_btn.click(
|
| 186 |
fn=finalize_current_chunk,
|
| 187 |
inputs=[],
|
| 188 |
outputs=[progress_text]
|
| 189 |
)
|
|
|
|
| 190 |
merge_btn.click(
|
| 191 |
fn=merge_all_chunks,
|
| 192 |
inputs=[],
|
| 193 |
outputs=[final_output, output_audio]
|
| 194 |
)
|
|
|
|
| 195 |
return demo
|
| 196 |
|
| 197 |
if __name__ == "__main__":
|
| 198 |
-
|
| 199 |
-
if
|
| 200 |
-
|
| 201 |
-
show_error=True,
|
| 202 |
-
share=False,
|
| 203 |
-
server_name="0.0.0.0",
|
| 204 |
-
server_port=7860
|
| 205 |
-
)
|
| 206 |
else:
|
| 207 |
logger.error("Failed to create the Gradio interface.")
|
|
|
|
| 11 |
# It's recommended to set the HUGGINGFACE_TOKEN as an environment variable
|
| 12 |
token = os.getenv("HUGGINGFACE_TOKEN")
|
| 13 |
|
| 14 |
+
def create_DubIndic_interface():
|
| 15 |
"""
|
| 16 |
Creates and configures the Gradio interface for the DubIndic application.
|
| 17 |
"""
|
|
|
|
| 23 |
except Exception as e:
|
| 24 |
logger.error("Error connecting to the private space: %s", e, exc_info=True)
|
| 25 |
# Create a fallback interface to show the connection error
|
| 26 |
+
with gr.Blocks() as demo:
|
| 27 |
+
gr.Markdown("# π¬ DubIndic - Connection Error")
|
| 28 |
+
gr.Textbox(
|
| 29 |
+
value=f"Failed to connect to the Hugging Face Space. Please ensure the Space is running and the token is correct. Error: {e}",
|
| 30 |
+
label="Error",
|
| 31 |
+
interactive=False
|
| 32 |
+
)
|
| 33 |
return demo
|
| 34 |
|
| 35 |
# Define wrapper functions to call the API endpoints
|
| 36 |
def start_processing(audio_file, target_language):
|
| 37 |
if not audio_file or not target_language:
|
|
|
|
| 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)
|
| 45 |
result = client.predict(
|
| 46 |
audio_file=handle_file(audio_file),
|
|
|
|
| 48 |
api_name="/process_audio_pipeline_step1"
|
| 49 |
)
|
| 50 |
logger.info("Received result from step 1: %s", result)
|
| 51 |
+
|
| 52 |
+
# API returns a 7-element tuple, we map it to our UI outputs
|
| 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):
|
| 67 |
+
# The API uses different endpoints for next/previous navigation
|
| 68 |
+
# We assume /lambda is for previous and /lambda_1 is for next
|
| 69 |
api_to_call = "/lambda" if direction == "prev" else "/lambda_1"
|
| 70 |
try:
|
| 71 |
logger.info("Calling %s to navigate.", api_to_call)
|
| 72 |
+
result = client.predict(
|
| 73 |
+
t=transcription,
|
| 74 |
+
tr=translation,
|
| 75 |
+
api_name=api_to_call
|
| 76 |
+
)
|
| 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:
|
|
|
|
| 87 |
return None
|
| 88 |
try:
|
| 89 |
logger.info("Calling /generate_dubbed_chunk.")
|
|
|
|
| 90 |
dubbed_path = client.predict(
|
| 91 |
transcription=transcription,
|
| 92 |
translation=translation,
|
| 93 |
api_name="/generate_dubbed_chunk"
|
| 94 |
)
|
| 95 |
logger.info("Received dubbed chunk: %s", dubbed_path)
|
|
|
|
| 96 |
return dubbed_path
|
| 97 |
except Exception as e:
|
| 98 |
logger.error("Error generating dubbed chunk: %s", e, exc_info=True)
|
|
|
|
| 99 |
return None
|
| 100 |
|
| 101 |
def finalize_current_chunk():
|
|
|
|
| 103 |
logger.info("Calling /finalize_current_chunk.")
|
| 104 |
progress = client.predict(api_name="/finalize_current_chunk")
|
| 105 |
logger.info("Received finalization progress: %s", progress)
|
| 106 |
+
return progress
|
|
|
|
| 107 |
except Exception as e:
|
| 108 |
logger.error("Error finalizing chunk: %s", e, exc_info=True)
|
| 109 |
+
return f"Error finalizing chunk: {e}"
|
|
|
|
| 110 |
|
| 111 |
def merge_all_chunks():
|
| 112 |
try:
|
| 113 |
logger.info("Calling /merge_audio_files.")
|
|
|
|
| 114 |
final_status, final_audio = client.predict(api_name="/merge_audio_files")
|
| 115 |
logger.info("Received final merged audio.")
|
| 116 |
+
return final_status, final_audio
|
|
|
|
| 117 |
except Exception as e:
|
| 118 |
logger.error("Error merging audio files: %s", e, exc_info=True)
|
| 119 |
+
return f"Error merging audio: {e}", None
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
+
# Create custom theme with orange-red gradient colors
|
| 122 |
+
custom_theme = gr_themes.Soft(
|
| 123 |
+
primary_hue="orange",
|
| 124 |
+
secondary_hue="red",
|
| 125 |
+
neutral_hue="gray"
|
| 126 |
+
).set(
|
| 127 |
+
button_primary_background_fill="linear-gradient(45deg, #f97316, #ef4444)",
|
| 128 |
+
button_primary_background_fill_hover="linear-gradient(45deg, #ea580c, #dc2626)",
|
| 129 |
+
button_primary_text_color="white",
|
| 130 |
+
block_background_fill="rgba(255, 255, 255, 0.05)",
|
| 131 |
+
block_border_color="rgba(249, 115, 22, 0.2)",
|
| 132 |
+
input_background_fill="rgba(255, 255, 255, 0.9)",
|
| 133 |
+
input_border_color="rgba(249, 115, 22, 0.3)",
|
| 134 |
+
input_border_color_focus="rgba(239, 68, 68, 0.6)"
|
| 135 |
+
)
|
| 136 |
|
| 137 |
+
# Define the Gradio Interface using Blocks for a custom layout
|
| 138 |
+
with gr.Blocks(theme=custom_theme, title="DubIndic - AI Audio Dubbing", css="""
|
| 139 |
+
.gradio-container {
|
| 140 |
+
background: linear-gradient(135deg, rgba(249, 115, 22, 0.1), rgba(239, 68, 68, 0.1));
|
| 141 |
+
}
|
| 142 |
+
.gr-button[variant="primary"] {
|
| 143 |
+
background: linear-gradient(45deg, #f97316, #ef4444) !important;
|
| 144 |
+
border: none !important;
|
| 145 |
+
color: white !important;
|
| 146 |
+
font-weight: bold !important;
|
| 147 |
+
}
|
| 148 |
+
.gr-button[variant="primary"]:hover {
|
| 149 |
+
background: linear-gradient(45deg, #ea580c, #dc2626) !important;
|
| 150 |
+
transform: translateY(-1px);
|
| 151 |
+
box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
|
| 152 |
+
}
|
| 153 |
+
.gr-button[variant="secondary"] {
|
| 154 |
+
background: linear-gradient(45deg, rgba(249, 115, 22, 0.1), rgba(239, 68, 68, 0.1)) !important;
|
| 155 |
+
border: 2px solid #f97316 !important;
|
| 156 |
+
color: #f97316 !important;
|
| 157 |
+
font-weight: bold !important;
|
| 158 |
+
}
|
| 159 |
+
.gr-button[variant="secondary"]:hover {
|
| 160 |
+
background: linear-gradient(45deg, #f97316, #ef4444) !important;
|
| 161 |
+
color: white !important;
|
| 162 |
+
}
|
| 163 |
+
h1 {
|
| 164 |
+
background: linear-gradient(45deg, #f97316, #ef4444);
|
| 165 |
+
-webkit-background-clip: text;
|
| 166 |
+
-webkit-text-fill-color: transparent;
|
| 167 |
+
background-clip: text;
|
| 168 |
+
font-weight: bold;
|
| 169 |
+
}
|
| 170 |
+
.gr-textbox {
|
| 171 |
+
border: 2px solid rgba(249, 115, 22, 0.3) !important;
|
| 172 |
+
}
|
| 173 |
+
.gr-textbox:focus {
|
| 174 |
+
border-color: #ef4444 !important;
|
| 175 |
+
box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
|
| 176 |
+
}
|
| 177 |
+
""") as demo:
|
| 178 |
+
gr.Markdown("# π¬ DubIndic - AI Audio Dubbing Pipeline")
|
| 179 |
+
gr.Markdown("Transform your audio into another Indian language with full editing control.")
|
| 180 |
+
|
| 181 |
+
with gr.Row():
|
| 182 |
+
with gr.Column(scale=1):
|
| 183 |
+
gr.Markdown("### π€ Step 1: Upload & Configure")
|
| 184 |
audio_input = gr.Audio(sources=["upload"], type="filepath", label="π΅ Upload Audio File")
|
| 185 |
lang_dropdown = gr.Dropdown(
|
| 186 |
choices=["Assamese", "Bengali", "Gujarati", "Hindi", "Kannada", "Malayalam", "Marathi", "Odia", "Punjabi", "Tamil", "Telugu"],
|
| 187 |
label="π Target Language"
|
| 188 |
)
|
| 189 |
+
process_btn = gr.Button("π― Start Processing", variant="primary")
|
| 190 |
+
|
| 191 |
+
step1_output = gr.Textbox(label="π Processing Status", interactive=False)
|
| 192 |
+
|
| 193 |
+
with gr.Column(visible=False) as edit_section:
|
| 194 |
+
gr.Markdown("### βοΈ Step 2: Edit, Generate & Finalize Chunks")
|
| 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():
|
| 202 |
+
generate_btn = gr.Button("π Generate Dubbed Chunk")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
finalize_btn = gr.Button("βοΈ Finalize Chunk", variant="secondary")
|
| 204 |
+
dubbed_audio = gr.Audio(label="Dubbed Chunk Audio", type="filepath", interactive=False)
|
| 205 |
+
progress_text = gr.Textbox(label="Progress", interactive=False)
|
| 206 |
+
|
| 207 |
+
with gr.Row(visible=False) as merge_section:
|
| 208 |
gr.Markdown("### π Step 3: Merge Final Audio")
|
| 209 |
merge_btn = gr.Button("π Merge All Finalized Chunks", variant="primary")
|
| 210 |
+
|
| 211 |
+
final_output = gr.Textbox(label="π Final Results", interactive=False)
|
| 212 |
+
output_audio = gr.Audio(label="π Final Dubbed Audio", type="filepath", interactive=False)
|
| 213 |
|
| 214 |
# Connect functions to UI components
|
| 215 |
process_btn.click(
|
|
|
|
| 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(
|
| 234 |
fn=generate_dubbed_chunk,
|
| 235 |
inputs=[transcription_text, translation_text],
|
| 236 |
outputs=[dubbed_audio]
|
| 237 |
)
|
| 238 |
+
|
| 239 |
finalize_btn.click(
|
| 240 |
fn=finalize_current_chunk,
|
| 241 |
inputs=[],
|
| 242 |
outputs=[progress_text]
|
| 243 |
)
|
| 244 |
+
|
| 245 |
merge_btn.click(
|
| 246 |
fn=merge_all_chunks,
|
| 247 |
inputs=[],
|
| 248 |
outputs=[final_output, output_audio]
|
| 249 |
)
|
| 250 |
+
|
| 251 |
return demo
|
| 252 |
|
| 253 |
if __name__ == "__main__":
|
| 254 |
+
DubIndic_interface = create_DubIndic_interface()
|
| 255 |
+
if DubIndic_interface:
|
| 256 |
+
DubIndic_interface.launch(show_error=True, share=False, server_name="0.0.0.0", server_port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
else:
|
| 258 |
logger.error("Failed to create the Gradio interface.")
|