Skip to main content

Voice Activity Detection (VAD) package for audio/video processing

Project description

VAD Service README

This document provides instructions and API documentation for the Python-based Voice Activity Detection (VAD) service.

Overview

The VAD service is a FastAPI application that analyzes audio files to detect speech segments. It uses the Silero VAD model for accurate and efficient voice detection.

Getting Started

Prerequisites

  • Python 3.9+
  • pip for package management

Installation

  1. Navigate to the service directory:

    cd scripts/python/vad
    
  2. Install the required dependencies:

    pip install -r requirements.txt
    

Running the Service

To run the service locally, use uvicorn:

uvicorn main:app --host 0.0.0.0 --port 3102 --reload

The service will be available at http://localhost:3102.

API Documentation

The complete and interactive API documentation is available at http://localhost:3102/docs when the service is running.

Endpoints

POST /api/vad/analyze

Analyzes an audio file for voice activity.

Request Body: multipart/form-data

  • audioFile (file, required): The audio or video file to analyze.
  • threshold (number, optional, default: 0.3): VAD sensitivity threshold (0.0 to 1.0).
  • minSegmentDuration (number, optional, default: 0.3): Minimum duration for a speech segment in seconds.
  • maxMergeGap (number, optional, default: 0.0): Maximum silence duration between segments to be merged, in seconds.
  • exportAudioSegments (boolean, optional, default: true): Whether to export detected speech segments as individual audio files.
  • outputFormat (string, optional, default: "wav"): Format for exported audio segments (wav or flac).
  • requestId (string, optional): A unique ID for the request. If not provided, one will be generated.

Example cURL Request:

curl -X POST "http://localhost:3102/api/vad/analyze" \
     -F "audioFile=@/path/to/your/audio.wav" \
     -F "minSegmentDuration=0.5"

Success Response (200):

Returns a JSON object with detailed analysis results. See the VADAnalysisResponse schema in the OpenAPI specification for the full structure.

GET /api/vad/results/{requestId}/{filename}

Retrieves an artifact generated during analysis, such as the timestamps.json file or an exported audio segment.

Path Parameters:

  • requestId (string, required): The ID of the analysis request.
  • filename (string, required): The name of the file to retrieve.

Example cURL Request:

# Get the timestamps file
curl -X GET "http://localhost:3102/api/vad/results/your-request-id/timestamps.json"

# Get an audio segment
curl -X GET "http://localhost:3102/api/vad/results/your-request-id/segment_0_1.23_4.56.wav"

GET /api/health

Checks the health of the service, including directory permissions and model status.

GET /api/info

Provides general information about the service, its version, and capabilities.

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

lansonai_vadtools-0.2.0.tar.gz (6.2 MB view details)

Uploaded Source

Built Distribution

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

lansonai_vadtools-0.2.0-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file lansonai_vadtools-0.2.0.tar.gz.

File metadata

  • Download URL: lansonai_vadtools-0.2.0.tar.gz
  • Upload date:
  • Size: 6.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for lansonai_vadtools-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f362d9e80639c4d4b88b72024f58d4e705861c4bef6d53df25534b99929e911b
MD5 9168ced6e93ab38eb5ed4e6499701792
BLAKE2b-256 6828298d51c51702706a3049d3d38f94558aec41ae1632df7a831d63e4e38d6d

See more details on using hashes here.

File details

Details for the file lansonai_vadtools-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for lansonai_vadtools-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b41a1241ad2993ba78a9223703ef7d38965a2f779db6a57d993be2e35a90a4e
MD5 0c39a0f453594950239ef1090d2f8cd1
BLAKE2b-256 beed7f752f3d3bc03b6589313269c0a9b363d8c00f832f39a54ede17c96a1052

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