RustSilence is a supercharged Rust implementation of pydub's silence detection module, designed for blazing-fast audio preprocessing. Leveraging the speed and safety of Rust, RustSilence can detect silent segments in WAV, MP3, FLAC, OGG, and more — all in a fraction of the time it takes in Python.
pydub is great for quick scripting, but it struggles in performance-critical tasks like real-time TTS. This project combines:
- 🦀 Rust’s speed
- 🔊 Symphonia’s audio decoding
- 🔇 pydub’s silence detection
- 🐍 pyO3 Python bindings
to build a rock-solid preprocessing module for F5-TTS and beyond.
- 🎙️ Mono support only
- 🎧 Decode audio using Symphonia (bits per sample for fmt_ext PCM sub-type must be <= 32 bits)
- 🔇 Detect silence (via
pydub.silence) - 🐍 Python-compatible via pyO3
$pip install rust-silenceimport rust_silence
# Accepts WAV, MP3, FLAC, etc.
# Returns a NumPy array (mono, float32)
audio_np, sample_rate = rust_silence.from_file("example.mp3")
silence = rust_silence.detect_silence(audio_np, sample_rate)Audio loading & resampling powered by Symphonia, silence trimming via pydub.silence.
| Task | Python | Rust (pyO3) |
|---|---|---|
| from_file | ~160 ms | ~4 ms |
| detect_silence | ~700 ms | ~17 ms |
| detect_nonsilent | ~700 ms | ~17 ms |
| split_on_silence | ~700 ms | ~17 ms |
| detect_leading_silence | ~280 μs | ~9 μs |
** audio duration 10s and sample rate 32,000 (~320,000 samples) **
Symphonia provides native decoding, multi-format support, and fast performance—ideal for preprocessing pipelines like F5-TTS.
- Rust engine
- pyO3 integration
- Silence detection (from
pydub)
- Symphonia — fast, accurate audio decoding
- pydub — simple silence detection
- pyO3 — clean Rust ↔ Python bindings
MIT