Skip to main content

A .NET wrapper for the TEN-VAD (Voice Activity Detection) native library.

Total Downloads
227
227
Published
Mar 31, 2026
6mo ago

Get Started

dotnet add package TenVadSharp --version 1.0.0
ProductVersions
.NET
net8.0

README

TenVadSharp

NuGet License

A .NET wrapper for the TEN-VAD voice activity detection native library, providing real-time speech detection capabilities for audio processing applications.

Installation

Install via the NuGet Package Manager:

dotnet add package TenVadSharp

Or via the Package Manager Console:

Install-Package TenVadSharp

Quick Start

using TenVadSharp;

class Detector : IDisposable
{
   public Detector(ITenVad vad)
   {
      this.vad = vad;
      vad.Initialize(hopSize: 256, threshold: 0.5f);
   }

   ITenVad vad;

   public void DetectAudio(ReadOnlySpan<short> samples)
   {
      vad.Process(samples, out float probability, out bool hasSpeech);
      Console.WriteLine($"Speech detected: {hasSpeech}; Probability: {probability}");
   }

   public void Dispose()
   {
      vad.Dispose();
   }
}

Configuration Guide

See the TEN-VAD documentation for updated information on supported sampling rates and hop sizes.

⚠️ As of this writing, the library only supports 16kHz.

Hop Size

The number of samples between the start points of two consecutive analysis frames. (e.g., 256).

⚠️ Optimized hop sizes are 160 or 256 samples.

Threshold

The VAD detection threshold ranges from [0.0, 1.0]. This threshold is used to determine voice activity by comparing with the output probability. When probability >= threshold, voice is detected.

Platform Support

Platform Architecture Status
Windows x64 ✅ Supported
Windows x86 ✅ Supported

API Reference

ITenVad Interface

Interface for the TEN VAD voice activity detector for DI and testing.

Constructors

ITenVad()

Constructs a new TEN VAD instance. Requires initialization after construction.

ITenVad(uint hopSize, float threshold)

Constructs a new TEN VAD instance with the specified hop size and threshold.

Parameters:

  • hopSize - The number of samples between the start points of two consecutive analysis frames (e.g., 256).
  • threshold - The VAD detection threshold ranging from [0.0, 1.0]. This threshold is used to determine voice activity by comparing with the output probability. When probability >= threshold, voice is detected.

Throws:

  • ArgumentOutOfRangeException - If threshold is not between 0.0 and 1.0

Properties

Property Type Description
HopSize uint Gets the number of samples between the start points of two consecutive analysis frames (e.g., 256).
Threshold float Gets the VAD detection threshold ranging from [0.0, 1.0]. This threshold is used to determine voice activity by comparing with the output probability. When probability >= threshold, voice is detected.

Methods

Initialize(uint hopSize, float threshold)

Initializes the VAD instance with the specified parameters.

Parameters:

  • hopSize - The number of samples between the start points of two consecutive analysis frames (e.g., 256).
  • threshold - The VAD detection threshold ranging from [0.0, 1.0]. This threshold is used to determine voice activity by comparing with the output probability. When probability >= threshold, voice is detected.

Throws:

  • InvalidOperationException - If already initialized or initialization fails
  • ArgumentOutOfRangeException - If threshold is not between 0.0 and 1.0
Process(short[] samples, out float probability, out bool hasSpeech)

Processes an audio frame and detects voice activity.

Parameters:

  • samples - Audio samples as 16-bit PCM data (must match HopSize length)
  • probability - Receives the voice activity probability in the range [0.0, 1.0], where higher values indicate higher confidence in voice presence.
  • hasSpeech - Receives the binary voice activity decision: 0: no voice, 1: voice detected. This flag is set to 1 when out_probability >= threshold, and 0 otherwise.

Returns:

  • bool - true if processing succeeded, false otherwise

Throws:

  • InvalidOperationException - If not initialized
  • ObjectDisposedException - If instance has been disposed
  • ArgumentException - If samples array length doesn't match HopSize
Process(ReadOnlySpan<short> samples, out float probability, out bool hasSpeech)

Processes an audio frame and detects voice activity.

Parameters:

  • samples - Audio samples as 16-bit PCM data (must match HopSize length)
  • probability - Receives the voice activity probability in the range [0.0, 1.0], where higher values indicate higher confidence in voice presence.
  • hasSpeech - Receives the binary voice activity decision: 0: no voice, 1: voice detected. This flag is set to 1 when out_probability >= threshold, and 0 otherwise.

Returns:

  • bool - true if processing succeeded, false otherwise

Throws:

  • InvalidOperationException - If not initialized
  • ObjectDisposedException - If instance has been disposed
  • ArgumentException - If samples array length doesn't match HopSize
Dispose()

Releases native resources.

TenVad Class

Managed wrapper for the TEN VAD real-time voice activity detector.

Implements ITenVad.

Properties

Also includes one static property for version information:

Property Type Description
Version string (static) Gets the TEN VAD library version string. Can be called without initializing an instance.

Downloads by Version

Not enough data for chart

Similar & Alternative Packages

Hand-picked matching NuGet libraries based on tags & ecosystem

Depended On By

Find packages that declare this package as a dependency. NuGet does not provide a reverse-dependency endpoint, so candidates are checked on demand.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.