Spaces:
Runtime error
A newer version of the Gradio SDK is available: 6.19.0
title: Does It Sound Broken
emoji: π
colorFrom: yellow
colorTo: red
sdk: gradio
sdk_version: 5.50.0
python_version: '3.10'
app_file: app.py
short_description: Diagnose appliance faults from sound.
pinned: false
tags:
- hackathon
- build-small
- backyard-ai
- nvidia/NVIDIA-Nemotron-3-Nano-4B-BF16
- tiny-titan
- off-brand
- well-tuned
- audio
- appliance-diagnosis
- edge-inference
π Does It Sound Broken?
Record 10 seconds of an appliance. Get back what's wrong, how urgent, and what to check first β grounded in measured acoustics, explained by a 4B model.
Elevator pitch
Mechanical faults announce themselves acoustically long before failure, but ordinary people can't decode the sound and a technician callout costs more than the diagnosis is worth. This app closes that gap: deterministic DSP extracts ~14 acoustic features, a transparent rule engine ranks likely faults, and NVIDIA Nemotron-3-Nano-4B explains the best-supported one in plain language. The model never hears raw audio β it reasons only over confirmed measurements, which is exactly why a 4B model is reliable here.
β¨ Features
- ποΈ Record or upload β diagnose 12 appliance types
- π¬ 14 deterministic acoustic features (librosa/scipy, on Modal)
- π§ Transparent rule-grounded fault ranking (no hallucinated faults)
- π¦ Urgency banner (CRITICAL β LOW) + 3 concrete checks + safety note
- π§Ύ "Evidence" panel: every diagnosis traces to a measured value and a rule
- π Before/after compare tab β prove the fix measurably worked
- π‘οΈ Hardened: silence, clipping, NaN, corrupt files, stereo, and runaway model output are all handled β the UI never crashes (106 passing tests)
- π No audio stored
π§ How it works
HF Space (thin Gradio client)
β audio bytes + appliance
βΌ
Modal GPU container ββ librosa features ββΊ trained anomaly detector (DCASE 2025)
ββΊ rule engine ranks candidates
ββΊ structured prompt ββΊ Nemotron-3-Nano-4B + LoRA ββΊ validated JSON
β result dict
βΌ
HF Space renders verdict + evidence
Limited resources by design: the Space does NO heavy compute β it only ships
audio to Modal and renders the answer. All librosa/torch/transformers work runs in
the Modal image on Modal's hardware. The rule engine is the floor: the model can
refine and explain, but cannot name a fault the measurements don't support
(json_guard.py snaps ungrounded output back).
ποΈ Architecture
| File | Role | Runs on |
|---|---|---|
app.py |
Thin Gradio client (only gradio + modal) |
HF Space |
modal_backend.py |
GPU class running the whole pipeline | Modal (A100-40GB) |
audio_analyzer.py |
Deterministic 14-feature extraction | Modal |
fault_rules.py |
Per-appliance rule tables β ranked candidates | Modal |
feature_prompt.py |
Formats facts + candidates into the prompt | Modal |
json_guard.py |
Validates output, guarantees a safe result | Modal |
finetune/train.py |
DCASE 2025 classifier + LoRA training pipeline | Modal (CPU/GPU) |
mock_model.py |
Deterministic LLM stand-in for tests/dry-runs | local |
Model: nvidia/NVIDIA-Nemotron-3-Nano-4B-BF16 (override with MODEL_ID).
π Run locally
pip install -r requirements.txt # thin client deps (gradio, modal)
python assets/generate_samples.py # create test WAVs
# UI only, no Modal/GPU (canned output):
SOUNDBROKEN_MOCK=1 python app.py
# Real backend: deploy Modal once, then run the client:
modal deploy modal_backend.py
python app.py
βοΈ Deploy
- Modal backend:
modal deploy modal_backend.py(the image installs librosa/torch/transformers; weights cache on a Modal Volume). - HF Space: SDK Gradio, free CPU tier is enough (thin client). Add your
Modal credentials as Space secrets:
MODAL_TOKEN_ID,MODAL_TOKEN_SECRET. - First request cold-starts the Modal container (~20β30 s); then it's warm.
π§ͺ Sample audio
sample_washer_bearing.wavβ rhythmic 4 Hz impacts (bearing fault)sample_fan_imbalanced.wavβ 50 Hz hum with amplitude wobble (imbalance)sample_motor_squeal.wavβ 2.5 kHz modulated tone (belt/brush squeal)sample_washer_good.wavβ steady hum (healthy baseline)
π§ͺ Trained ML models
Anomaly detector (binary: normal vs anomaly)
- Dataset: DCASE 2025 Task 2 (
HTill/dcase2025_task2_dev) β real industrial machine audio - Accuracy: 71.2% | ROC-AUC: 0.725 | 5-fold CV AUC: 0.758 Β± 0.025
- Features: 14 deterministic librosa features (RMS, spectral centroid, onset rate, harmonic ratio, etc.)
- Ensemble: VotingClassifier (GradientBoosting + RandomForest, soft voting)
- Threshold: Youden-J optimal 0.45 (balanced) / 0.22 (safety-mode, β₯80% recall)
- Per-machine accuracy: bearing 66%, fan 72%, gearbox 70%, slider 66%, valve 82%
LoRA fine-tune (Well-Tuned badge)
- Base:
nvidia/NVIDIA-Nemotron-3-Nano-4B-BF16with LoRA (r=16, alpha=32) - Targets: q_proj, v_proj, k_proj, o_proj (1.59M trainable params, 0.04%)
- Training: 300 pairs Γ 2 epochs on A100-80GB, loss 1.85 β 0.72
- Pairs: DCASE clips β (features + rule candidates β grounded JSON response)
- Adapter:
mitvho09/sound-broken-nemotron-loraon HF Hub - Inference: Manual weight merging (no peft at runtime) β LoRA fused into base model weights at container start for transformers 5.x compatibility
π Future work
- More domains: HVAC, power tools, vehicles
- On-device GGUF (Q4_K_M) build for offline field use
- Trend analysis with before/after comparison
π Hackathon tracks
Judges' Wildcard Β· Backyard AI Β· NVIDIA Nemotron Quest Β· Tiny Titan Β· Off-Brand Β· Well-Tuned
π License
Apache-2.0
π₯ Contributors
- You