https://github.com/zygotecode/vadsharp
Enterprise VAD (Voice Activity Detection) in C#.NET (.NET 6.0+) with Microsoft.ML.Net, ONNXRuntime and DirectML. The easiest, efficient, and performant Silero VAD implementation! Always open for PRs.
https://github.com/zygotecode/vadsharp
csharp dotnet onnx onnx-runtime onnxruntime silero-vad speech speech-processing vad voice-activity-detection voice-control voice-recognition
Last synced: 4 months ago
JSON representation
Enterprise VAD (Voice Activity Detection) in C#.NET (.NET 6.0+) with Microsoft.ML.Net, ONNXRuntime and DirectML. The easiest, efficient, and performant Silero VAD implementation! Always open for PRs.
- Host: GitHub
- URL: https://github.com/zygotecode/vadsharp
- Owner: ZygoteCode
- License: mit
- Created: 2025-02-03T20:47:26.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-20T20:08:40.000Z (about 1 year ago)
- Last Synced: 2025-04-20T21:23:31.576Z (about 1 year ago)
- Topics: csharp, dotnet, onnx, onnx-runtime, onnxruntime, silero-vad, speech, speech-processing, vad, voice-activity-detection, voice-control, voice-recognition
- Language: C#
- Homepage:
- Size: 354 KB
- Stars: 12
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# VadSharp - Voice Activity Detection in C#.NET
    
## 🚀 The Best VAD Implementation in C#
VadSharp is the **first and most efficient** implementation of **[Silero VAD](https://github.com/snakers4/silero-vad/) in C#**, supporting the latest **V5 model** with all its advanced features. It is faster than the original Python version and runs on **any GPU (NVIDIA, AMD, Intel) and CPU** with **ONNXRuntime and DirectML**.
This project represents **my first significant contribution to the world of artificial intelligence in terms of development**, and I sincerely hope that users will appreciate this effort. Your support and feedback are highly valued! 🙌
---
## 🛠 Features & Benefits
✅ **Stellar Accuracy** - Excellent results in speech detection tasks.
⚡ **Fast** - Processes 30ms+ audio chunks in under **1ms** on a single CPU thread, even faster with batching or GPU acceleration.
📦 **Lightweight** - Model size is only **~2MB**.
🌎 **General** - Trained on **6,000+ languages**, handling various background noises and recording conditions.
🎚 **Flexible Sampling Rate** - Supports **8000 Hz and 16000 Hz**.
🌍 **Highly Portable** - Runs anywhere **ONNX and ML.NET** are available.
🔓 **No Strings Attached** - **MIT License**, no telemetry, no registration, no vendor lock-in.
---
## 📌 Installation
```sh
# Install ONNXRuntime and ML.NET
Install-Package Microsoft.ML.OnnxRuntime
Install-Package Microsoft.ML
Install-Package NAudio
```
---
## 🧑💻 Example Usage
```csharp
using System.Text;
using VadSharp;
public class Program
{
private const int SAMPLE_RATE = 16000;
private const float THRESHOLD = 0.5f;
private const int MIN_SPEECH_DURATION_MS = 250;
private const float MAX_SPEECH_DURATION_SECONDS = float.PositiveInfinity;
private const int MIN_SILENCE_DURATION_MS = 100;
private const int SPEECH_PAD_MS = 30;
public static void Main()
{
Console.Title = "VadSharpExample | Made by https://github.com/GabryB03/";
string modelPath = Path.Combine(AppContext.BaseDirectory, "resources", "silero_vad.onnx");
string audioPath = Path.Combine(AppContext.BaseDirectory, "resources", "test.wav");
if (!File.Exists(modelPath))
{
Console.WriteLine($"Model file not found: {modelPath}");
return;
}
if (!File.Exists(audioPath))
{
Console.WriteLine($"Audio file not found: {audioPath}");
return;
}
VadDetector vadDetector = new VadDetector(modelPath, THRESHOLD, SAMPLE_RATE, MIN_SPEECH_DURATION_MS, MAX_SPEECH_DURATION_SECONDS, MIN_SILENCE_DURATION_MS, SPEECH_PAD_MS);
List speechTimeList = vadDetector.GetSpeechSegmentList(audioPath);
StringBuilder sb = new StringBuilder();
foreach (VadSpeechSegment speechSegment in speechTimeList)
{
sb.AppendLine($"[-] Start second: {speechSegment.StartSecond.ToString().Replace(",", ".")}s, end second: {speechSegment.EndSecond.ToString().Replace(",", ".")}s");
}
Console.WriteLine(sb.ToString());
Console.ReadLine();
}
}
```
---
## 🌟 Contributing
Contributions are welcome there! 🚀 Follow these steps to create a **Pull Request (PR):**
1. **Fork the repository**
2. **Clone your fork**:
```sh
git clone https://github.com/your-username/VadSharp.git
```
3. **Create a new branch**:
```sh
git checkout -b feature-branch
```
4. **Make your changes & commit**:
```sh
git add .
git commit -m "Your awesome feature!"
```
5. **Push the branch & create a PR**:
```sh
git push origin feature-branch
```
6. **Open a PR on GitHub**
---
## 🐛 Issues & Bug Reports
If you find a bug or have a feature request, please **open an issue**:
1. Go to the [Issues Tab](https://github.com/GabryB03/VadSharp/issues).
2. Click on **"New Issue"**.
3. Provide a **clear and concise** description of the problem.
4. If possible, include **screenshots and logs**.
I will review and respond ASAP! 🚀
---
## ✨ Credits
All of my credits go to the original inventor of the [Silero VAD](https://github.com/snakers4/silero-vad/) project,
which has worked hard to the architecture of the algorithm and trained the models!
## 📜 License
VadSharp is licensed under the **MIT License**. Feel free to use, modify, and distribute it as you like!
📌 **Made with ❤️ by [GabryB03](https://github.com/GabryB03/)**