Skip to main content

Tool for slicing long audio files for datasets

Project description

Audio Slicer

License: MIT Python 3.8+

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 -r requirements.txt

PIP Installation

pip install lm-audioslicer

PIP usage

lm-audioslicer /path/to/audio/folder [options]

Usage

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

python audioslicer.slice ./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.4.tar.gz (7.0 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.4-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lm_audioslicer-0.1.4.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

Hashes for lm_audioslicer-0.1.4.tar.gz
Algorithm Hash digest
SHA256 24093185e15a91e8a07345847f2c58aaf6ce53cdc15ec308abc78f5f244c0d45
MD5 e195e804f57a5626ad5552c50d6d3966
BLAKE2b-256 0326553c579021ed89946a6818ce9fd99d0c627f63f3e5c443ff6860b47eac0a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lm_audioslicer-0.1.4-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

Hashes for lm_audioslicer-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a1d92ef8379461ad6d2f79b7714526ed2652529250334f246a678502c46e86be
MD5 fbb30ff1b9e06923629f4f1ae28d0907
BLAKE2b-256 7c303483b465de18ee5e1a2a0618fb23288532037bcd1bdf3d99bb8670985298

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