A Python tool for automatically slicing audio files based on silence detection, designed for creating ML datasets and processing large audio collections.
- Automatic silence detection using RMS analysis
- Batch processing of WAV and MP3 files
- Random word generation for unique file naming
- Configurable silence thresholds and segment lengths
- Maintains original sample rate
You can install audioslicer either via pip or by cloning the repository:
pip install lm_audioslicergit clone https://github.com/LarsMonstad/audioslicer.git
cd audioslicer
pip install -r requirements.txtlm_audioslicer /path/to/audio/folder [options]python -m audioslicer.slicer /path/to/audio/folder [options]-t, --threshold: Silence threshold in dB (default: -40.0)-l, --min_length: Minimum segment length in ms (default: 5000)-i, --min_interval: Minimum silence interval in ms (default: 300)-s, --hop_size: Analysis window size in ms (default: 10)-m, --max_silence: Maximum silence to keep in ms (default: 1000)
python audioslicer.slicer -m ./my_audio -t -35 -l 3000lm_audioslicer ./my_audio -t -35 -l 3000- Analyzes audio using RMS (root mean square) to detect silence
- Identifies silence regions below the threshold
- Splits audio at optimal points within silence regions
- Generates unique filenames using random pronounceable words
- Saves segments in a new 'sliced_audio' directory
- Creates 'sliced_audio' folder in the input directory
- Naming format:
originalname_randomword_number.wav - Preserves original audio quality and sample rate
- Minimum segment length prevents creation of tiny clips
- Hop size affects precision vs processing speed
- Maximum silence parameter trims long silence periods
- Uses librosa for robust audio processing
- Inspired by GUI Audio Slicer
MIT License
Made by Lars Monstad