Python class implementing WebRTC VAD with frame generation, detection, and segment conversion.
# Source: https://github.com/mangeshraut712/ai-ml-portfolio | License: MIT | Copyright 2026 Mangesh Raut
# Provided via justclaw.it.com; keep this notice with the code.
"""WebRTC GMM-based Voice Activity Detector."""
from __future__ import annotations
import numpy as np
import webrtcvad
from postprocess import apply_hangover, flags_to_segments
class WebRTCVADEngine:
"""Frame-level speech detector using WebRTC's GMM classifier.
WebRTC VAD accepts only 8/16/32/48 kHz mono PCM and frame lengths of
10, 20, or 30 ms. Aggressiveness ranges from 0 (lax) to 3 (strict).
"""
VALID_SAMPLE_RATES = {8000, 16000, 32000, 48000}
VALID_FRAME_MS = {10, 20, 30}
def __init__(self, aggressiveness: int = 2):
if aggressiveness not in range(4):
raise ValueErr
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key