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.2.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.2-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lm_audioslicer-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 3aeba04aa1dabde1e73d326c81392f178a200a6c22298148806b3ea89ac13e86
MD5 29569769d271c86f955847b1e9586d66
BLAKE2b-256 68d8429306532b8572f1b008ad308e00babc04d1f006d85e3ef616f5ebc675f3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lm_audioslicer-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 421ded6f3ab419fd1444926296845060aa97b8bb27aba3224da1cd7eea6c6d02
MD5 914f0598773f0a27c65d75e316cdc8c7
BLAKE2b-256 1f7ff1ef2f2291bb3580cd049faf1e89ea267e782da9ce2c8a6cb8907c187476

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