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

Uploaded Python 3

File details

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

File metadata

  • Download URL: audio_splitter_vad-0.1.0.tar.gz
  • Upload date:
  • Size: 3.1 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.0.tar.gz
Algorithm Hash digest
SHA256 4d831ef7f06435b3270f2ec715bf58010aef613c679deecd051aedda07d52d7b
MD5 c3761662fb442bb5d3b780ed9b4c115d
BLAKE2b-256 a756d0667298c25b1a8c7d2a7a599dab2dc362bde4e13b60af48c5c87bf1570d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: audio_splitter_vad-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 59ac2c6d3e0516ce7fad1dec358cf48fffff7e571fa2ad346b0a5ca09c223259
MD5 2739a30010ef76c0765f02d39669da4d
BLAKE2b-256 3e26b3676366aded13ceabf0516ee7c72cf082c8b8dffed89f201c8dac257a7f

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