TenVadSharp 1.0.0
dotnet add package TenVadSharp --version 1.0.0
NuGet\Install-Package TenVadSharp -Version 1.0.0
<PackageReference Include="TenVadSharp" Version="1.0.0" />
<PackageVersion Include="TenVadSharp" Version="1.0.0" />
<PackageReference Include="TenVadSharp" />
paket add TenVadSharp --version 1.0.0
#r "nuget: TenVadSharp, 1.0.0"
#:package TenVadSharp@1.0.0
#addin nuget:?package=TenVadSharp&version=1.0.0
#tool nuget:?package=TenVadSharp&version=1.0.0
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. |
| Product | Versions 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. |
-
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 |