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

Uploaded Python 3

File details

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

File metadata

  • Download URL: lm_audioslicer-0.1.5.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.5.tar.gz
Algorithm Hash digest
SHA256 ebd89437863cc83e98928a3cf8f3956ca3b50ec8485e93ff2033b684e408a0ef
MD5 d64d9f36407e559ab4b036a03ab674d5
BLAKE2b-256 aad6a28ca810b7701625195214f119f0be68a5e7ee7631200addad37216f93e9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lm_audioslicer-0.1.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ed5c7709ace34eeb8198ca91c7a842a8a765c2d4a6a4368fe88a1c8331bc09cc
MD5 a46133825b2d60b5354bf68bd7e14c2a
BLAKE2b-256 2f775a33851850707d833166d27bc6f6a57e47dfa89e7f9e0e128cbfd611ef53

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