Metadata-Version: 2.1
Name: lm_audioslicer
Version: 0.1.7
Summary: Tool for slicing long audio files for datasets
Home-page: https://github.com/LarsMonstad/audioslicer
Author: Lars Monstad
Author-email: Lars Monstad <lars.monstad@gmail.com>
License: MIT License
        
        Copyright (c) 2024 Lars Løberg Monstad
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/LarsMonstad/audioslicer
Project-URL: Issues, https://github.com/LarsMonstad/audioslicer/issues
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: librosa==0.9.1
Requires-Dist: soundfile>=0.12.1
Requires-Dist: numpy==1.23.5

# Audio Slicer
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)

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 
```bash
pip install -r requirements.txt
```

## PIP Installation 
```bash
pip install lm_audioslicer
```


## PIP usage 
```bash
lm_audioslicer /path/to/audio/folder [options]
```


## Usage
```bash
python audioslicer.slice /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
```bash
python audioslicer.slice ./my_audio -t -35 -l 3000
```

### PIP example
```bash
lm_audioslicer ./my_audio -t -35 -l 3000
```

## How It Works
1. Analyzes audio using RMS (root mean square) to detect silence
2. Identifies silence regions below the threshold
3. Splits audio at optimal points within silence regions  
4. Generates unique filenames using random pronounceable words
5. 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](https://github.com/flutydeer/audio-slicer)

## License
MIT License

---
Made by Lars Monstad
