Tool for slicing long audio files for datasets
Project description
Audio Slicer
A Python tool for automatically slicing audio files based on silence detection, designed for creating ML datasets and processing large audio collections.
Features
- 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
Installation
pip install librosa numpy soundfile
Usage
python audio_slicer.py /path/to/audio/folder [options]
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)
Example
python audio_slicer.py ./my_audio -t -35 -l 3000
How It Works
- 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
Output
- Creates 'sliced_audio' folder in the input directory
- Naming format:
originalname_randomword_number.wav - Preserves original audio quality and sample rate
Technical Notes
- 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
Acknowledgments
- Inspired by GUI Audio Slicer
License
MIT License
Made by Lars Monstad
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lm_audioslicer-0.1.0.tar.gz
(7.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lm_audioslicer-0.1.0.tar.gz.
File metadata
- Download URL: lm_audioslicer-0.1.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d82da6c1e49aedbeaa1efd59fe6d7e3321a96cdca20bdb4f7383e13e3163804
|
|
| MD5 |
edd15d7fbff892b5eda2ecc17ac31385
|
|
| BLAKE2b-256 |
871b50ad448546f25f140f95e2992a6ecd876a0bb54d8994de39c26b740119f1
|
File details
Details for the file lm_audioslicer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: lm_audioslicer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b03ba6c5badf986c760c2de7c3203be724f55f1471f7c63382a5101b7211e01
|
|
| MD5 |
043e1af633a9b722349ee8014cc1db8d
|
|
| BLAKE2b-256 |
d4ba65e10b8e237f0b834e695a7d02562fb2eb36e1bbed44f89841ba70da0271
|