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.
What this does
Spectral Eraser is an interactive tool for removing unwanted sounds by painting over their time‑frequency representation. The process is simple:
- The selected sound is exported to a temporary WAV.
- A Python script computes its spectrogram and opens a GUI where you can draw on it.
- Each stroke erases the corresponding STFT bins (sets them to zero).
- The modified spectrogram is inverted back to audio, and the result is imported into Praat.
- 🎧 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
- In Praat, select exactly one Sound object (mono or stereo – stereo will be downmixed to mono for processing).
- Run script… →
Spectral_Eraser.praat. - Choose an FFT_size:
- 512 (fast, low frequency resolution)
- 1024 (balanced)
- 2048 (high resolution)
- 4096 (very high, slower GUI)
- Click OK. A Python GUI opens showing the spectrogram (black background, warm colour scale).
- Draw on the spectrogram – left‑click and drag to erase regions (a red overlay marks erased areas).
- Adjust the Brush size slider at the top to control the stroke width.
- Use Clear All to reset the mask.
- When satisfied, click Apply to process and close the GUI.
- Praat imports the result as
originalname_erasedand optionally plays it.
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
- Brush slider – adjust the brush size (2–60 pixels). Larger brushes are faster for broad areas.
- Clear All – reset the entire mask (undo all erasures).
- Status bar – shows the time, frequency, and the percentage of the spectrogram that has been erased.
- Apply – process the mask, reconstruct audio, write output, and close GUI.
- Cancel – close GUI without processing.
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
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 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:
- Input waveform (grey).
- Output waveform (blue).
- Original spectrogram (0–5 kHz).
- Erased spectrogram (0–5 kHz) – this shows the result of the erasure.
- Summary panel – source name, FFT size, hop, duration, sample rate.
FAQ / troubleshooting
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.
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.
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.
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.
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 %.