denizaybey commited on
Commit
9989a8a
·
2 Parent(s): 32b3359 b313b80

Merge branch 'content-moderation-implementation' into 'main'

Browse files
Files changed (1) hide show
  1. app.py +88 -33
app.py CHANGED
@@ -50,6 +50,30 @@ def process_audio(original_audio_path, dubbed_audio_path, email, company_name, t
50
  return "Processing started. Results will be emailed to you shortly."
51
 
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  # Create a professional Gradio interface using the Golden ratio (1.618) for proportions
54
  # Define custom CSS for a professional look
55
  css = """
@@ -253,39 +277,63 @@ with gr.Blocks(css=css, theme=gr.themes.Soft(primary_hue="indigo", secondary_hue
253
  """)
254
 
255
  # Main content with specified layout
256
- # First Row: Half Original Audio Input, Half Dubbed Audio Input
257
- with gr.Row(elem_classes="input-section"):
258
- with gr.Column(scale=1):
259
- original_audio = gr.Audio(type="filepath", label="Original .wav file", sources=['upload'],format="wav")
260
- with gr.Column(scale=1):
261
- dubbed_audio = gr.Audio(type="filepath", label="Dubbed .wav file", sources=['upload'],format="wav")
262
-
263
- # Second Row: 2/3 Email Input 1/3 Company Name Input
264
- with gr.Row(elem_classes="input-section"):
265
- with gr.Column(scale=2):
266
- _email = gr.Textbox(label="Email")
267
- with gr.Column(scale=1):
268
- _company_name = gr.Textbox(label="Company Name")
269
-
270
- # Third Row: Tolerance Percentage
271
- with gr.Row(elem_classes="input-section"):
272
- _tolerance = gr.Slider(0, 100, value=5, label="Tolerance Percentage",
273
- info="Set the tolerance for audio comparison.")
274
-
275
- # Fourth Row: Processing Status
276
- with gr.Row(elem_classes="output-section"):
277
- output = gr.Text(label="Processing Status")
278
-
279
- with gr.Row():
280
- submit_btn = gr.Button("Process Audio", variant="primary")
281
-
282
- with gr.Row():
283
- gr.Markdown("### Results")
284
- gr.Markdown("Once processing is complete, results will be emailed to the address provided.")
285
-
286
- # Footer
287
- with gr.Row(elem_classes="footer"):
288
- gr.Markdown("© BSOD.tv - Professional Dub Quality Control")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
289
 
290
  # Set up the processing function
291
  submit_btn.click(
@@ -294,6 +342,13 @@ with gr.Blocks(css=css, theme=gr.themes.Soft(primary_hue="indigo", secondary_hue
294
  outputs=output
295
  )
296
 
 
 
 
 
 
 
 
297
  if __name__ == "__main__":
298
  # To run this file locally, you'll need to install gradio and requests:
299
  # pip install gradio requests
 
50
  return "Processing started. Results will be emailed to you shortly."
51
 
52
 
53
+ def process_video(video_path, notes, email, company_name):
54
+ """
55
+ Process the input video for content moderation.
56
+ Inputs:
57
+ - video_path: path to the uploaded video file (str)
58
+ - notes: department notes (str)
59
+ - email: contact email (str)
60
+ - company_name: company name (str)
61
+ Output:
62
+ - path to the output video file (str)
63
+ For now, this is a placeholder that returns the input video unchanged.
64
+ """
65
+ try:
66
+ # In a real implementation, you would trigger your backend processing here.
67
+ # For this demo, we simply return the original video path as the output.
68
+ if not video_path:
69
+ # Gradio expects None to clear the output component
70
+ return None
71
+ return video_path
72
+ except Exception as e:
73
+ logger.error(f"Error during video processing: {e}")
74
+ return None
75
+
76
+
77
  # Create a professional Gradio interface using the Golden ratio (1.618) for proportions
78
  # Define custom CSS for a professional look
79
  css = """
 
277
  """)
278
 
279
  # Main content with specified layout
280
+ with gr.Tabs():
281
+ with gr.Tab("Dub Quality Control"):
282
+ # First Row: Half Original Audio Input, Half Dubbed Audio Input
283
+ with gr.Row(elem_classes="input-section"):
284
+ with gr.Column(scale=1):
285
+ original_audio = gr.Audio(type="filepath", label="Original .wav file", sources=['upload'],format="wav")
286
+ with gr.Column(scale=1):
287
+ dubbed_audio = gr.Audio(type="filepath", label="Dubbed .wav file", sources=['upload'],format="wav")
288
+
289
+ # Second Row: 2/3 Email Input 1/3 Company Name Input
290
+ with gr.Row(elem_classes="input-section"):
291
+ with gr.Column(scale=2):
292
+ _email = gr.Textbox(label="Email")
293
+ with gr.Column(scale=1):
294
+ _company_name = gr.Textbox(label="Company Name")
295
+
296
+ # Third Row: Tolerance Percentage
297
+ with gr.Row(elem_classes="input-section"):
298
+ _tolerance = gr.Slider(0, 100, value=5, label="Tolerance Percentage",
299
+ info="Set the tolerance for audio comparison.")
300
+
301
+ # Fourth Row: Processing Status
302
+ with gr.Row(elem_classes="output-section"):
303
+ output = gr.Text(label="Processing Status")
304
+
305
+ with gr.Row():
306
+ submit_btn = gr.Button("Process Audio", variant="primary")
307
+
308
+ with gr.Row():
309
+ gr.Markdown("### Results")
310
+ gr.Markdown("Once processing is complete, results will be emailed to the address provided.")
311
+
312
+ # Footer
313
+ with gr.Row(elem_classes="footer"):
314
+ gr.Markdown("© BSOD.tv - Professional Dub Quality Control")
315
+ with gr.Tab("Content Moderation"):
316
+ # First Row: Left Department Notes (Textbox), Right Video input
317
+ with gr.Row(elem_classes="input-section"):
318
+ with gr.Column(scale=1):
319
+ cm_notes = gr.Textbox(label="Department Notes", lines=6, placeholder="Enter notes for the moderation team...")
320
+ with gr.Column(scale=1):
321
+ cm_video_in = gr.Video(label="Video Input", sources=["upload"], interactive=True)
322
+
323
+ # Second Row: Email and Company Name (2/3 and 1/3 columns)
324
+ with gr.Row(elem_classes="input-section"):
325
+ with gr.Column(scale=2):
326
+ cm_email = gr.Textbox(label="Email")
327
+ with gr.Column(scale=1):
328
+ cm_company_name = gr.Textbox(label="Company Name")
329
+
330
+ # Third Row: Single Video Output
331
+ with gr.Row(elem_classes="output-section"):
332
+ cm_video_out = gr.Video(label="Video Output")
333
+
334
+ # Final Row: Process button
335
+ with gr.Row():
336
+ cm_process_btn = gr.Button("Process", variant="primary")
337
 
338
  # Set up the processing function
339
  submit_btn.click(
 
342
  outputs=output
343
  )
344
 
345
+ # Wire Content Moderation processing
346
+ cm_process_btn.click(
347
+ fn=process_video,
348
+ inputs=[cm_video_in, cm_notes, cm_email, cm_company_name],
349
+ outputs=cm_video_out
350
+ )
351
+
352
  if __name__ == "__main__":
353
  # To run this file locally, you'll need to install gradio and requests:
354
  # pip install gradio requests