Shubham2004 commited on
Commit
3a099e1
Β·
verified Β·
1 Parent(s): 5bdbdac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +56 -55
app.py CHANGED
@@ -413,73 +413,74 @@ Keep the tone warm, empathetic, and parent-friendly. Plain text only."""
413
  return f"❌ Error generating analysis: {str(e)}"
414
 
415
 
416
- # ── Gradio Interface ───────────────────────────────────────────────────────
417
 
418
- with gr.Blocks(title="Developmental Stuttering Detection") as demo:
419
- gr.Markdown("# 🎀 Developmental Stuttering Detection")
420
- gr.Markdown("Upload a recording of a child speaking to screen for signs of stutter-like disfluencies.")
421
-
422
- with gr.Tabs():
423
- # TAB 1: Prediction
424
- with gr.Tab("Analysis"):
425
- with gr.Row():
426
- audio_input = gr.Audio(
427
- type="filepath",
428
- label="Upload Audio (WAV recommended, min 4 seconds)"
429
- )
430
- threshold_slider = gr.Slider(
431
- minimum=0.1,
432
- maximum=0.9,
433
- value=0.5,
434
- step=0.05,
435
- label="SLD Threshold",
436
- info="Lower = more sensitive, Higher = more conservative"
 
 
 
 
 
 
 
 
 
 
 
 
437
  )
438
 
439
- analyze_btn = gr.Button("πŸ” Analyze", variant="primary")
440
-
441
- with gr.Row():
442
- results_output = gr.JSON(label="Raw Results")
443
- summary_output = gr.Textbox(label="Summary", lines=10)
444
-
445
- analyze_btn.click(
446
- fn=analyze_speech,
447
- inputs=[audio_input, threshold_slider],
448
- outputs=[results_output, summary_output]
449
- )
 
 
 
 
 
 
 
 
450
 
451
- # TAB 2: Detailed Analysis (Gemini-powered)
452
- with gr.Tab("Detailed Report"):
453
- gr.Markdown("Generate a detailed clinical-style report powered by AI.")
454
-
455
- audio_input_2 = gr.Audio(type="filepath", label="Upload Audio")
456
- child_name_input = gr.Textbox(value="Child", label="Child's Name")
457
- child_age_input = gr.Textbox(value="?", label="Child's Age")
458
- threshold_slider_2 = gr.Slider(
459
- minimum=0.1, maximum=0.9, value=0.5, step=0.05, label="SLD Threshold"
460
- )
461
-
462
- generate_btn = gr.Button("πŸ“„ Generate Report", variant="primary")
463
- report_output = gr.Textbox(label="Generated Report", lines=15)
464
-
465
- generate_btn.click(
466
- fn=generate_analysis,
467
- inputs=[audio_input_2, child_name_input, child_age_input, threshold_slider_2],
468
- outputs=report_output
469
- )
470
-
471
- gr.Markdown("""
472
  ---
473
  ⚠️ **IMPORTANT DISCLAIMER**
474
 
475
  This tool is a **screening aid only** and does not constitute a clinical diagnosis.
476
  All results must be reviewed by a qualified Speech-Language Pathologist.
477
-
478
- For more information, consult a healthcare professional.
479
  """)
 
 
480
 
481
 
482
- # ── Launch ─────────────────────────────────────────────────────────────────
483
 
484
  if __name__ == "__main__":
 
485
  demo.launch(share=False)
 
413
  return f"❌ Error generating analysis: {str(e)}"
414
 
415
 
416
+ # ── Gradio Interface (Simplified) ──────────────────────────────────────────
417
 
418
+ def create_demo():
419
+ with gr.Blocks(title="Developmental Stuttering Detection") as demo:
420
+ gr.Markdown("# 🎀 Developmental Stuttering Detection")
421
+ gr.Markdown("Upload a recording of a child speaking to screen for signs of stutter-like disfluencies.")
422
+
423
+ with gr.Tabs():
424
+ # TAB 1: Prediction
425
+ with gr.Tab("Analysis"):
426
+ with gr.Row():
427
+ audio_input = gr.Audio(
428
+ type="filepath",
429
+ label="Upload Audio (WAV recommended, min 4 seconds)"
430
+ )
431
+ threshold_slider = gr.Slider(
432
+ minimum=0.1,
433
+ maximum=0.9,
434
+ value=0.5,
435
+ step=0.05,
436
+ label="SLD Threshold"
437
+ )
438
+
439
+ analyze_btn = gr.Button("πŸ” Analyze", variant="primary")
440
+
441
+ with gr.Row():
442
+ results_output = gr.JSON(label="Raw Results")
443
+ summary_output = gr.Textbox(label="Summary", lines=10)
444
+
445
+ analyze_btn.click(
446
+ fn=analyze_speech,
447
+ inputs=[audio_input, threshold_slider],
448
+ outputs=[results_output, summary_output]
449
  )
450
 
451
+ # TAB 2: Detailed Analysis
452
+ with gr.Tab("Detailed Report"):
453
+ gr.Markdown("Generate a detailed clinical-style report powered by AI.")
454
+
455
+ audio_input_2 = gr.Audio(type="filepath", label="Upload Audio")
456
+ child_name_input = gr.Textbox(value="Child", label="Child's Name")
457
+ child_age_input = gr.Textbox(value="?", label="Child's Age")
458
+ threshold_slider_2 = gr.Slider(
459
+ minimum=0.1, maximum=0.9, value=0.5, step=0.05, label="SLD Threshold"
460
+ )
461
+
462
+ generate_btn = gr.Button("πŸ“„ Generate Report", variant="primary")
463
+ report_output = gr.Textbox(label="Generated Report", lines=15)
464
+
465
+ generate_btn.click(
466
+ fn=generate_analysis,
467
+ inputs=[audio_input_2, child_name_input, child_age_input, threshold_slider_2],
468
+ outputs=report_output
469
+ )
470
 
471
+ gr.Markdown("""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
472
  ---
473
  ⚠️ **IMPORTANT DISCLAIMER**
474
 
475
  This tool is a **screening aid only** and does not constitute a clinical diagnosis.
476
  All results must be reviewed by a qualified Speech-Language Pathologist.
 
 
477
  """)
478
+
479
+ return demo
480
 
481
 
482
+ # ── Launch ──────────────────────────────────────────────────────────────────
483
 
484
  if __name__ == "__main__":
485
+ demo = create_demo()
486
  demo.launch(share=False)