TenVadSharp 1.0.0

dotnet add package TenVadSharp --version 1.0.0
                    
NuGet\Install-Package TenVadSharp -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TenVadSharp" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TenVadSharp" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="TenVadSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TenVadSharp --version 1.0.0
                    
#r "nuget: TenVadSharp, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TenVadSharp@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TenVadSharp&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=TenVadSharp&version=1.0.0
                    
Install as a Cake Tool

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.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 48 3/31/2026