Spectral Eraser — v1.0 User Guide

Interactive time‑frequency eraser. Opens a Python/tkinter GUI showing the spectrogram of the selected sound. The user draws on it to silence specific frequency‑time regions. Uses STFT → mask → iSTFT round‑trip. Perfect for removing unwanted noise, clicks, or isolating specific spectral elements.

Author: Shai Cohen Affiliation: Department of Music, Bar‑Ilan University, Israel Version: 1.0 (2025) License: MIT License Repo: GitHub
Contents:

What this does

Spectral Eraser is an interactive tool for removing unwanted sounds by painting over their time‑frequency representation. The process is simple:

Use cases:
  • 🎧 Noise removal – remove unwanted broadband noise or specific frequency bands.
  • 🎤 Vocal isolation – erase background sounds while preserving the voice.
  • 🔬 Research – silence specific spectral components for auditory experiments.
  • 🎨 Creative – create spectral “holes” for sound design.

Quick start

  1. In Praat, select exactly one Sound object (mono or stereo – stereo will be downmixed to mono for processing).
  2. Run script… → Spectral_Eraser.praat.
  3. Choose an FFT_size:
    • 512 (fast, low frequency resolution)
    • 1024 (balanced)
    • 2048 (high resolution)
    • 4096 (very high, slower GUI)
  4. Click OK. A Python GUI opens showing the spectrogram (black background, warm colour scale).
  5. Draw on the spectrogram – left‑click and drag to erase regions (a red overlay marks erased areas).
  6. Adjust the Brush size slider at the top to control the stroke width.
  7. Use Clear All to reset the mask.
  8. When satisfied, click Apply to process and close the GUI.
  9. Praat imports the result as originalname_erased and optionally plays it.
Tip: Use a larger FFT size (2048 or 4096) for better frequency resolution when erasing narrow bands. Use a smaller FFT size (512) for faster GUI response and better time resolution when erasing short transients.
Important: Python dependencies: numpy, soundfile, tkinter (tkinter is included with standard Python). The GUI may take a few seconds to open for long files. The tool works best with mono signals; stereo is automatically downmixed.

The Spectral Eraser GUI

🎨 Interface preview

┌─────────────────────────────────────────────────────────────────┐
│ Brush: [====●===] [Clear All] SR 44100 Hz | 3.45 s | FFT 2048 │
├─────────────────────────────────────────────────────────────────┤
│ ████████ ← Spectrogram (click & drag to erase) █
│ │
│ ← red overlay shows erased regions │
│ │
├─────────────────────────────────────────────────────────────────┤
│ Time: 1.234 s | Freq: 2450 Hz | Erased: 12% │
├─────────────────────────────────────────────────────────────────┤
│ [Cancel] [▶ Apply] │
└─────────────────────────────────────────────────────────────────┘

Controls

The spectrogram uses a warm colour map (black → purple → red → yellow). Frequency labels (100 Hz, 250 Hz, 1 kHz, etc.) are drawn on the left edge. The canvas is scrollable horizontally for long sounds.

FFT size trade‑offs

FFT sizeFrequency resolutionTime resolutionGUI speedBest for bonjour512~86 Hz per bin (44.1 kHz)~11.6 ms frameFastestBroadband noise, transients 1024~43 Hz~23.2 msFastGeneral purpose 2048~21.5 Hz~46.4 msModerateNarrow‑band tones, harmonics 4096~10.8 Hz~92.8 msSlowerVery narrow bands, high precision

The hop size is always FFT_size / 4, giving 75 % overlap for smooth reconstruction. Larger FFT sizes give better frequency resolution but poorer time resolution and slower GUI response.

Pipeline — five stages

Stage 1 – Export (Praat) – convert to mono, export to temporary WAV.
Stage 2 – STFT (Python) – compute forward STFT with Hann window, 75 % overlap.
Stage 3 – GUI (Python/tkinter) – display spectrogram, user paints mask (sets STFT bins to zero).
Stage 4 – iSTFT (Python) – apply mask, reconstruct time‑domain signal with overlap‑add normalisation.
Stage 5 – Import (Praat) – read output WAV, rename, scale peak to 0.95, visualise.

The mask is applied directly to the complex STFT matrix (magnitude and phase), so erased bins are truly silenced, not just attenuated.

Visualization (Praat picture)

When Draw_visualization = 1, the script draws a multi‑panel figure:

Tip: Compare the original and erased spectrograms to see exactly which regions were silenced. The output waveform shows the effect on the overall amplitude.

FAQ / troubleshooting

“Python not found” or missing tkinter

Install Python 3 (with tkinter) and ensure it’s in your PATH. On Windows, the script tries python, py, py -3, and python3. Install numpy and soundfile: pip install numpy soundfile.

GUI opens but Apply does nothing / crashes

Check the terminal where you launched Praat for error messages. Common issues: memory exhaustion for very large FFT sizes (4096) on long files, or numpy version conflicts. Try a smaller FFT size (1024) first.

Output has clicks / artefacts at erasure boundaries

The STFT/iSTFT reconstruction uses 75 % overlap, which normally gives smooth transitions. If you erase large contiguous areas, the abrupt loss of energy may still cause slight audible edges. For cleaner results, avoid erasing very narrow vertical slivers (short in time). The mask is binary – future versions may support smooth crossfades.

Why does the spectrogram look different from Praat’s?

Python’s spectrogram uses the same STFT parameters (FFT size, Hann window, 75 % overlap) but the colour map and dynamic range scaling are different. The display is optimised for visibility (5th to 99th percentile dB range) rather than absolute values. This makes faint details visible.

Erased percentage

The status bar shows the percentage of STFT bins that have been set to zero. A value of 100 % would produce silence; typical erasures are 10–50 %.