Skip to main content

Tool for slicing long audio files for datasets

Project description

AudioSlicer

License: MIT Python 3.8+ Librosa NumPy SoundFile

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

You can install audioslicer either via pip or by cloning the repository:

Using pip

pip install lm_audioslicer

From source

git clone https://github.com/LarsMonstad/audioslicer.git
cd audioslicer
pip install -r requirements.txt

PIP usage

lm_audioslicer /path/to/audio/folder [options]

Usage

python -m audioslicer.slicer /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 audioslicer.slicer -m ./my_audio -t -35 -l 3000

PIP example

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

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.8.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lm_audioslicer-0.1.8-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file lm_audioslicer-0.1.8.tar.gz.

File metadata

  • Download URL: lm_audioslicer-0.1.8.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.8.18

File hashes

Hashes for lm_audioslicer-0.1.8.tar.gz
Algorithm Hash digest
SHA256 d0f5f55f45de6ab61628b6e35cd9b7571e9f764542943306f4880356694aca0d
MD5 82b2535d4528cf56d9ff95293a139b24
BLAKE2b-256 7bd2fba89732212ddc813b3beddb2ff9e658ef899a97b3e3f1528050e64e643a

See more details on using hashes here.

File details

Details for the file lm_audioslicer-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: lm_audioslicer-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.8.18

File hashes

Hashes for lm_audioslicer-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 3d6a49e98ab63cd6dfc4685d0eac8352f29cc726101533637a89d7870fe2a633
MD5 20ea9a344e4e5f27f7f32915a3542c41
BLAKE2b-256 5d79afad93718161e20ade7f69a1353fed303343e08ee6ad6acbfcca3044300d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page