Update app.py
Browse files
app.py
CHANGED
@@ -166,6 +166,14 @@ def mock_analytics():
|
|
166 |
"Instagram": {"Views": random.randint(500, 3000), "Engagement Rate": f"{random.uniform(10, 20):.2f}%"},
|
167 |
}
|
168 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
# Core functionalities
|
170 |
def upload_and_manage(file, language):
|
171 |
if file is None:
|
@@ -216,10 +224,16 @@ def build_interface():
|
|
216 |
submit_button = gr.Button("Post and Process")
|
217 |
|
218 |
with gr.Column(scale=5):
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
with gr.Column(scale=1):
|
224 |
gr.Markdown("**Feedback**")
|
225 |
feedback_input = gr.Textbox(
|
@@ -238,10 +252,16 @@ def build_interface():
|
|
238 |
return message, gr.update(value=file_path, visible=True)
|
239 |
return message, gr.update(visible=False)
|
240 |
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
submit_button.click(
|
242 |
upload_and_manage,
|
243 |
inputs=[file_input, language_input],
|
244 |
-
outputs=[
|
245 |
)
|
246 |
# Connect submit button to save_feedback_db function
|
247 |
feedback_btn.click(
|
|
|
166 |
"Instagram": {"Views": random.randint(500, 3000), "Engagement Rate": f"{random.uniform(10, 20):.2f}%"},
|
167 |
}
|
168 |
|
169 |
+
def update_translations(file, edited_translations):
|
170 |
+
output_video_path = "output_video.mp4"
|
171 |
+
updated_translations = json.loads(edited_translations)
|
172 |
+
|
173 |
+
add_transcript_to_video(file.name, translated_json, output_video_path)
|
174 |
+
|
175 |
+
return output_video_path
|
176 |
+
|
177 |
# Core functionalities
|
178 |
def upload_and_manage(file, language):
|
179 |
if file is None:
|
|
|
224 |
submit_button = gr.Button("Post and Process")
|
225 |
|
226 |
with gr.Column(scale=5):
|
227 |
+
|
228 |
+
gr.Markdown("## Edit Translations")
|
229 |
+
editable_translations = gr.Textbox(
|
230 |
+
label="Edit Translated Texts (JSON Format)",
|
231 |
+
lines=10,
|
232 |
+
interactive=True
|
233 |
+
)
|
234 |
+
save_changes_button = gr.Button("Save Changes")
|
235 |
+
processed_video_output = gr.File(label="Download Processed Video", interactive=True) # Download button
|
236 |
+
|
237 |
with gr.Column(scale=1):
|
238 |
gr.Markdown("**Feedback**")
|
239 |
feedback_input = gr.Textbox(
|
|
|
252 |
return message, gr.update(value=file_path, visible=True)
|
253 |
return message, gr.update(visible=False)
|
254 |
|
255 |
+
save_changes_button.click(
|
256 |
+
update_translations,
|
257 |
+
inputs=[file_input, editable_translations],
|
258 |
+
outputs=[processed_video_output]
|
259 |
+
)
|
260 |
+
|
261 |
submit_button.click(
|
262 |
upload_and_manage,
|
263 |
inputs=[file_input, language_input],
|
264 |
+
outputs=[editable_translations, processed_video_output]
|
265 |
)
|
266 |
# Connect submit button to save_feedback_db function
|
267 |
feedback_btn.click(
|