Skip to main content

A fast, multithreaded audio silence remover and chunk slicer.

Project description

Audio Splitter VAD 🎙️✂️

A lightning-fast, production-ready Python library for audio silence removal and multithreaded chunking.

Built on top of Google's robust WebRTC Voice Activity Detection (VAD) engine, this tool allows you to strip silence from audio files and slice pure speech into manageable chunks. It is fully optimized for scale, featuring both I/O-bound multithreading for single massive files and CPU-bound multiprocessing for directories with thousands of files.


Features

  • Silence Stripping: Automatically detect and remove non-speech frames using WebRTC VAD.
  • Smart Slicing: Yield continuous chunks of pure speech at any desired duration.
  • Universal Input: Natively accepts .mp3 and .wav files and automatically converts them into the 16-bit mono PCM format required by WebRTC.
  • Multithreaded Export: Bypass the GIL by saving hundreds of chunks to disk concurrently.
  • Batch Processing: Utilize all CPU cores via multiprocessing to process thousands of audio files at maximum speed.

Installation

Install the package via pip (or uv):

pip install audio-splitter-vad

⚠️ System Requirement

This library uses pydub under the hood to decode .mp3 files. You must have FFmpeg installed on your system and available in your PATH.

Install FFmpeg

macOS

brew install ffmpeg

Linux

sudo apt install ffmpeg

Windows

Download FFmpeg from gyan.dev or install it with:

winget install ffmpeg

Quick Start

1. Memory-Efficient Generator (Streaming)

Ideal for streaming chunks directly to transcription APIs like Whisper or Google Cloud without saving them to disk.

from audio_splitter_vad.splitter import Splitter

audio_splitter = Splitter()

# Yield 5-second chunks of pure speech (silence removed)
for chunk in audio_splitter.split(
    "podcast.mp3",
    slice_duration=5,
    strip_silence=True,
):
    print(f"Received {len(chunk)} bytes of pure speech!")
    # Send chunk to your API...

2. High-Speed Multithreaded Slicing (Single File)

Quickly split a single massive audio file into hundreds of .wav chunks on your hard drive.

from audio_splitter_vad.splitter import Splitter

audio_splitter = Splitter()

# Save chunks concurrently using background threads
saved_files = audio_splitter.split_multithreaded(
    audio_path="massive_interview.wav",
    save_path="./clean_chunks",
    slice_duration=5,
    max_workers=8,
    strip_silence=True,
)

print(f"Successfully exported {len(saved_files)} chunks.")

3. Core-Max Batch Processing (Directories)

If you have a folder containing thousands of audio files, use multiprocessing instead of multithreading. This assigns an isolated VAD engine to every CPU core for maximum throughput.

from audio_splitter_vad.batch_split import batch_process_directory

batch_process_directory(
    input_folder="./raw_podcasts",
    output_folder="./processed_datasets",
    strip_silence=True,
)

Advanced Configuration

You can pass a custom WebRTC VAD engine when initializing Splitter to control how aggressively silence is removed.

Mode Description
0 Least aggressive (retains more background noise).
1 Light filtering.
2 Moderate filtering.
3 Most aggressive (removes nearly everything that is not speech).

Example:

import webrtcvad
from audio_splitter_vad.splitter import Splitter

# Less aggressive filtering
custom_vad = webrtcvad.Vad(1)

splitter = Splitter(vad_engine=custom_vad)

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

audio_splitter_vad-0.1.1.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

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

audio_splitter_vad-0.1.1-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file audio_splitter_vad-0.1.1.tar.gz.

File metadata

  • Download URL: audio_splitter_vad-0.1.1.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for audio_splitter_vad-0.1.1.tar.gz
Algorithm Hash digest
SHA256 690cc6090d5d24023a0b6ad58db4d4ae4705f3363fd16c79b1e54351700bdd99
MD5 3771f448cc87e9011765d6de41ac6234
BLAKE2b-256 d39eb2114c57297340484c5fa5d7b9a903ac4b18132dd403cc14d7a3da83bc1c

See more details on using hashes here.

File details

Details for the file audio_splitter_vad-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: audio_splitter_vad-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for audio_splitter_vad-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 89107a3dc8acc95bcf3d0e9f4468d93b0a7bfb3838d14ece2d81a1a8ca68aa21
MD5 e17c2118821ef8cc579cccbd7457b9f7
BLAKE2b-256 9b41b53467976c00e6e66ea9f26493edc98a89e91d9a5bd5a34463d29bd43454

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