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.7.tar.gz (7.3 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.7-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lm_audioslicer-0.1.7.tar.gz
  • Upload date:
  • Size: 7.3 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.7.tar.gz
Algorithm Hash digest
SHA256 46bfe6ee3070ae4ceaa9365184923c125bb6b6f3b17ea8bbeeff1af4167d881d
MD5 4ebe21e5d48439c0369b00df4f5b5a1a
BLAKE2b-256 11747130069d1f62ac4df5317ddf7806d9e4b251c88bc7ff95f36d693523c0e0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lm_audioslicer-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 7.0 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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 33bbe5e5f03e9e915d270878da018e5c0af2bc6bdf840ab9b4a65bd26321b85b
MD5 3495a5b4d107b0f302c63b98adef8a57
BLAKE2b-256 b2613b7f27c3105beb74b057db46422a70335a2005d648f42b2cb092ff41daac

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