A .NET wrapper for the TEN-VAD (Voice Activity Detection) native library.
Get Started
| Product | Versions |
|---|---|
| .NET |
README
TenVadSharp
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 failsArgumentOutOfRangeException- 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 matchHopSizelength)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-trueif processing succeeded,falseotherwise
Throws:
InvalidOperationException- If not initializedObjectDisposedException- If instance has been disposedArgumentException- If samples array length doesn't matchHopSize
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 matchHopSizelength)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-trueif processing succeeded,falseotherwise
Throws:
InvalidOperationException- If not initializedObjectDisposedException- If instance has been disposedArgumentException- If samples array length doesn't matchHopSize
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
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.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.