Skip to content

akaliutau/quietplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QuietPlace

AI semantic ANC powered by Gemma 4

Hero card

Adapt to the environment. Cancel the nuisance. Never cancel the signal that keeps someone safe.

Python Gemma vLLM Safety Local First


QuietPlace turns a noisy soundscape into an explainable, safety-aware controller plan. It suppresses traffic, fan hum, HVAC, engines, and other nuisance sounds while preserving sirens, speech, alarms, knocks, baby cries, and other safety-critical signals.


Quick demo · Architecture · Quickstart · Results · Safety · Project structure

Why it matters

Noise is not just discomfort. In a disaster shelter, a field clinic, a crowded dormitory, a classroom, or a home beside a road, noise steals sleep, focus, recovery, and dignity.

But ordinary noise cancellation has a dangerous flaw: it suppresses sound without understanding it.

A siren is not “noise.”
A baby cry is not “background.”
A voice saying “help” is not a frequency band to erase.

QuietPlace is our answer:

Adapt to the environment. Cancel the nuisance. Never cancel the signal that keeps someone safe.

What we built

QuietPlace is a safety-aware adaptive semantic noise suppression system:

  1. It listens to an audio scene.
  2. It detects events with an AST-style audio classifier.
  3. It summarizes compact spectral features such as dominant hum frequencies.
  4. It asks Gemma 4 to compile the soundscape into a structured controller policy.
  5. It executes only deterministic, whitelisted DSP operations.
  6. It outputs suppressed audio, charts, metrics, and an inspectable controller_policy.json.

The result is not just “quieter audio.” The result is auditable quiet: nuisance zones are reduced, protected sounds are copied back, and every controller decision is visible.

Quick demo

QuietPlace Architecture

The demo soundscape contains:

Segment Example source Policy
0.0s–4.9s Helicopter / traffic-like noise Suppress
6.2s–8.1s Siren Preserve
Full scene 120 / 240 / 360 Hz fan-hum pattern Suppress outside protected regions
Optional Human speech / help signal Preserve

Before and after waveform Input overview

Demo storyboard

  1. Play the original noisy scene.
  2. Show detected sound events on the spectrogram.
  3. Show Gemma 4 producing a controller plan.
  4. Execute only whitelisted DSP actions.
  5. Play the suppressed audio.
  6. Show metrics: nuisance energy drops; protected sounds remain.

Generated outputs live in runs/quietplace_demo/: original.wav, suppressed.wav, controller_policy.json, metrics_summary.json, CSV metric tables, and charts.

The Gemma 4 moment

Gemma 4 is not used as a caption generator. It is the local semantic policy compiler.

The model receives:

  • the user goal, for example: sleep in a shared shelter while preserving safety-critical sounds;
  • a timestamped event table from the classifier;
  • compact spectral features such as dominant frequencies and band-energy shares;
  • hard safety rules for protected sounds;
  • a whitelist of legal audio actions.

It returns a function-callable JSON controller plan:

{
  "preserve_segments_sec": [[6.2, 8.1], [10.5, 12.0]],
  "suppress_segments_sec": [[0.0, 6.2], [8.1, 10.5], [12.0, 14.0]],
  "actions": [
    {
      "function": "apply_notch",
      "args": {
        "frequencies_hz": [120, 240, 360],
        "quality_factor": 45,
        "target_segments_sec": [[0.0, 6.2], [8.1, 10.5], [12.0, 14.0]]
      }
    },
    {
      "function": "apply_semantic_spectral_gate",
      "args": {
        "reduction_db": 24,
        "preserve_segments_sec": [[6.2, 8.1], [10.5, 12.0]],
        "target_segments_sec": [[0.0, 6.2], [8.1, 10.5], [12.0, 14.0]]
      }
    },
    {
      "function": "copy_original_for_segments",
      "args": {
        "preserve_segments_sec": [[6.2, 8.1], [10.5, 12.0]]
      }
    }
  ],
  "explanation": "Traffic rumble and fan harmonics are suppressible; siren and speech may carry safety information."
}

That JSON is the center of the system. It is readable by humans, executable by the pipeline, and repairable by the safety normalizer before DSP runs.

Architecture

flowchart LR
    A[Audio scene] --> B[Windowing]
    B --> C[AST audio event classifier]
    B --> D[Spectral feature extractor]
    C --> E[Event table]
    D --> F[Dominant frequencies\nBand energy\nDuration]
    E --> G[Gemma 4 policy compiler]
    F --> G
    U[User goal\nSleep / study / shelter safety] --> G
    S[Hard safety rules\nPreserve siren, speech, alarm, baby cry] --> G
    G --> H[controller_policy.json]
    H --> I[Plan normalizer\nBoundary repair\nWhitelist enforcement]
    I --> J[Deterministic DSP executor]
    J --> K[Suppressed audio]
    J --> L[Metrics + charts]
Loading

Core design principle

QuietPlace separates intelligence from execution:

Layer Responsibility Why it matters
Audio classifier Detects event labels, time spans, confidence, and rough policy hints Converts raw audio into an auditable event table
Gemma 4 controller Maps the scene and user goal into a safe JSON DSP plan Makes semantic, context-aware policy decisions
Plan normalizer Repairs underspecified model output and recomputes safe intervals Prevents accidental suppression through protected windows
DSP executor Runs only whitelisted deterministic actions Keeps the system testable and safe
Metrics layer Measures calm-zone reduction and protected-sound retention Makes the demo judgeable

Safety by construction

QuietPlace treats model output as a recommendation, not as executable code.

Non-negotiable safety rules

  • Preserve sirens, alarms, speech, baby cries, knocks, shouts, help signals, and emergency vehicles.
  • Suppress nuisance only outside protected regions.
  • Split suppression segments around preserved segments.
  • Use only whitelisted functions:
    • apply_notch
    • apply_semantic_spectral_gate
    • copy_original_for_segments
  • Copy protected segments back from the original audio after all suppression.

Defensive programming model

If Gemma 4 returns a semantically good but underspecified plan, QuietPlace normalizes it before execution:

  • fills missing target_segments_sec;
  • recomputes suppressible intervals around protected intervals;
  • inserts notch filters for dominant 50–500 Hz hum components;
  • applies conservative fallback defaults when backend calls fail;
  • forces protected audio copy-back at the final DSP stage.

This is the key trust boundary: Gemma decides what is allowed; deterministic DSP decides how it happens.

Results

A demo run produces objective metrics in runs/quietplace_demo/metrics_summary.json.

Metric Demo value Meaning
duration_sec 14.0 Demo scene length
overall_rms_reduction_db 0.92 Whole-scene energy reduction
calm_zone_noise_reduction_db 2.851 Reduction in suppressible / calm-zone intervals
mean_suppressible_segment_reduction_db 0.92 Mean reduction in segments marked suppress
protected_audio_retention_pct 107.3 Protected windows are retained rather than erased
hum_band_reduction_db 3.005 120–380 Hz fan/engine band reduction
protected_segments_count 2 Preserved safety windows
suppressed_segments_count 2 Nuisance windows acted on

The most important result is behavioral: QuietPlace reduces nuisance energy while keeping sirens and speech audible.

Advanced acoustic simulations

QuietPlace includes optional room and ANC demos to show how semantic suppression can connect to real acoustic control.

ANC cancellation zone

The ANC demo uses a feed-forward filtered-x NLMS simulation to generate:

  • anc_before_listener.wav
  • anc_after_listener.wav
  • anc_antinoise_listener.wav
  • anc_interference_waveform.png
  • anc_spectrum_before_after.png
  • anc_convergence.png
  • anc_cancellation_zone.png
  • anc_metadata.json

The room demo generates listener-level metrics and heatmaps for before/after acoustic energy.

Quickstart

1. Clone

git clone https://github.com/akaliutau/quietplace.git
cd quietplace

2. Create an environment

conda create -n quietplace python=3.12 -y
conda activate quietplace

3. Install dependencies

pip install -r requirements.txt

For editable development:

python -m pip install -e ".[test]"

Run tests:

pytest -q

CLI reference

Command Purpose
quietplace make-demo-scene Build a realistic demo scene from held-out clips or synthetic fallback
quietplace run Classify events, ask Gemma/vLLM or fallback controller for a plan, execute DSP, write metrics
quietplace charts Produce before/after spectrograms, waveforms, segment metrics, and bandpower charts
quietplace room-demo Run semantic suppression through a small room model and save heatmaps
quietplace anc-demo Run filtered-x NLMS ANC simulation with cancellation/convergence plots
quietplace chapters Create markdown chapters for a hackathon writeup or demo script

Python API

from quietplace.demo_scene import create_demo_scene
from quietplace.pipeline import run_pipeline

scene = create_demo_scene("data/demo_scene")

run = run_pipeline(
    scene["audio"],
    "runs/quietplace_demo",
    events_json=scene["events"],
    backend="mock",
)

print(run["files"]["suppressed_audio"])
print(run["summary_metrics"])

Output files

runs/quietplace_demo/
  ├── original.wav
  ├── suppressed.wav
  ├── events.json
  ├── controller_policy.json
  ├── features.json
  ├── segment_metrics.csv
  ├── bandpower_metrics.csv
  ├── metrics_summary.json
  └── charts/
      ├── 01_before_after_spectrograms.png
      ├── 02_waveform_ab.png
      ├── 03_segment_metrics.png
      └── 04_bandpower_metrics.png

Project structure

quietplace/
  ├── audio.py          # audio IO, event schema, spectral features, masks
  ├── classifier.py     # AST classifier wrapper and policy mapping
  ├── controller.py     # Gemma/vLLM/Transformers policy compiler + plan normalizer
  ├── dsp.py            # deterministic notch + semantic spectral gate executor
  ├── metrics.py        # calm-zone, preservation, segment, and bandpower metrics
  ├── viz.py            # before/after plots and scorecards
  ├── demo_scene.py     # held-out clip mixer + synthetic fallback scene builder
  ├── pipeline.py       # end-to-end orchestration
  ├── room_sim.py       # room acoustic visualization demo
  ├── anc_sim.py        # feed-forward filtered-x NLMS ANC demo
  └── cli.py            # command-line interface

docs/
  ├── QuietPlace_Kaggle_Writeup.md
  └── QuietPlace_Final_Kaggle_Writeup.md

examples/
  └── README.md         # dataset and demo input guidance

tests/
  └── test_smoke.py     # synthetic scene + pipeline smoke test

How the DSP executor works

QuietPlace currently supports two practical suppression tools:

1. Harmonic notch filtering

Best for fan hum, engine idle, generator drone, HVAC tones, and synthetic 120/240/360 Hz nuisance.

{
  "function": "apply_notch",
  "args": {
    "frequencies_hz": [120, 240, 360],
    "quality_factor": 45,
    "target_segments_sec": [[0.0, 6.2], [8.1, 14.0]]
  }
}

2. Semantic spectral gate

Best for broadband nuisance such as road noise, fan wash, and low-frequency rumble.

{
  "function": "apply_semantic_spectral_gate",
  "args": {
    "reduction_db": 24,
    "target_segments_sec": [[0.0, 6.2], [8.1, 14.0]],
    "preserve_segments_sec": [[6.2, 8.1]]
  }
}

3. Protected copy-back

The final safety layer copies protected intervals from the original audio into the processed output with a crossfade.

{
  "function": "copy_original_for_segments",
  "args": {
    "preserve_segments_sec": [[6.2, 8.1], [10.5, 12.0]]
  }
}

Datasets for reproducible demos

The repository does not ship dataset audio. Recommended sources for demo scenes:

Purpose Dataset
Urban nuisance and sirens UrbanSound8K
General environmental sounds ESC-50
Traffic and roadway noise FSD50K
Real room/background ambience DEMAND
Consented spoken phrase Your own recording

Limitations

QuietPlace is a proof-of-concept, not a certified medical, emergency, or hearing-protection device.

Current limitations:

  • The demo uses mono 16 kHz audio.
  • Classifier quality depends on the exported AST model and training data.
  • Semantic DSP is not a replacement for high-end multi-microphone ANC hardware.
  • Protected-sound retention should be evaluated with more diverse real-world recordings.
  • Real-time mobile deployment needs additional latency, battery, and microphone-array work.

These limitations are also why the architecture is modular: the policy compiler, classifier, executor, room simulator, and ANC layer can improve independently.

Publishing

Build and check the package:

python -m build
python -m twine check dist/*

Upload to TestPyPI first:

python -m twine upload --repository testpypi dist/*

Then publish to PyPI:

python -m twine upload dist/*

See publish.md for the full release checklist.

License

See LICENSE.

The future is intelligent quiet.


Built exclusively for the Gemma 4 Good Hackathon organized by Google Deepmind.

About

QuietPlace - AI ANC noise suppressor

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors