A Python utility that processes audio files using two methods: Silero VAD (Voice Activity Detection) and FFmpeg. Both approaches remove silence and normalize audio output.
- Python 3.12.2
- FFmpeg version 2024-04-10-git-0e4dfa4709-full_build-www.gyan.dev
- Required Python packages (see requirements.txt):
- torch==2.5.1
- torchaudio==2.5.1
- Install Python 3.12.2
- Install FFmpeg and ensure it's in your system PATH
- Install required packages:
pip install -r requirements.txtRun the script with an input audio file (tested to work for mp3 and wav, other file formats may not be recognized):
python main.py path/to/audio/file.wavThe script will:
- Create a 'processed' subdirectory where the input file is located. I've included a media folder with an example test file.
- Process the file using both methods:
- Silero VAD:
{filename}_SileroVAD.wav - FFmpeg:
{filename}_FFmpeg.wav
- Silero VAD:
- Display processing statistics
- ML model based voice detection
- Adds 0.5s padding around speech segments
- Minimum speech duration: 0.5s
- Handles silence by trimming to 1 second
- Uses PyTorch backend
- Signal-based silence detection
- Silence threshold: -40dB
- Minimum silence duration: 1.0s
- Two-pass normalization
- Generates 1-second silent file for silent inputs
For each method, displays:
- Original duration (seconds)
- Processed duration (seconds)
- Reduction percentage
- Processing time
- Number of detected segments
The script handles:
- Missing input files
- Processing errors
- Silent audio files
- Windows/Unix path differences
- Temporary file cleanup