Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
| 419 |
-
gr.
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
with gr.
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 437 |
)
|
| 438 |
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 450 |
|
| 451 |
-
|
| 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)
|