Skip to main content

Slices audio clips into chunks of a specific number of seconds at the closest moment of silence (decided by silero-vad). Uses onnx which avoids the pytorch dependency.

Project description

vadslice

Slices audio clips of speech into chunks of certain length in seconds at silence points so it doesn't cut in the middle of someone speaking. It uses VAD (voice activity detection from silero-vad) to determine these points of silence within the clip.

Uses ONNX runtime instead of PyTorch, avoiding the heavy PyTorch dependency while maintaining the same VAD accuracy.

It's extremely fast.

Installation

Requires Python 3.12+.

uv add vadslice

or pip:

pip install vadslice

Usage

CLI

vadslice <size> <input_file> <output_dir> [--format wav|mp3|ogg|m4a]

Example:

vadslice 30 audio.mp3 ./chunks --format mp3

Chunks are saved to output_dir/input_file_stem/chunk_XXXX_offset_XX.XXs.ext.

Python API

from vadslice import slicer

parts = slicer("audio.mp3", slice_length_s=30.0)
for i, part in enumerate(parts):
    print(f"Part {i}: Offset: {part.offset_s}s, Size: {len(part.part)} bytes")

The function slicer returns a list of AudioPart objects, each containing:

  • part: WAV bytes (16 kHz mono) for that slice
  • offset_s: Start time offset in seconds from the original audio

Supports any audio format that PyAV can decode (MP3, WAV, OGG, M4A, FLAC, etc.).

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

vadslice-1.0.2.tar.gz (2.0 MB view details)

Uploaded Source

Built Distribution

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

vadslice-1.0.2-py3-none-any.whl (2.0 MB view details)

Uploaded Python 3

File details

Details for the file vadslice-1.0.2.tar.gz.

File metadata

  • Download URL: vadslice-1.0.2.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.24

File hashes

Hashes for vadslice-1.0.2.tar.gz
Algorithm Hash digest
SHA256 a3d7a6f7ca485703bfca1bd86c3b2bb840c7fcb4e76bebdd145d359899a957c5
MD5 12c9e1c63f2525318b7ca89acb7bd597
BLAKE2b-256 78273b28edc654f6e3ec0baad7703975381e4215d488c90e90b3490196d627d6

See more details on using hashes here.

File details

Details for the file vadslice-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: vadslice-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.24

File hashes

Hashes for vadslice-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3b6cb253dd744c0f72ad1b2963b938cbcaaece7f9fe5ba25e3687fa9bcc2e8ec
MD5 cd205c5ddd2d7ff7908468d02147a133
BLAKE2b-256 2c81cf1269b11a1a7b1f22adfdce6e56f43383ea2454cae12d1aaefff77a98d8

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