Skip to content

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.

License

Notifications You must be signed in to change notification settings

ZygoteCode/VadSharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VadSharp - Voice Activity Detection in C#.NET

VadSharp ML.NET ONNXRuntime DirectML PRs Welcome

🚀 The Best VAD Implementation in C#

VadSharp is the first and most efficient implementation of 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

# Install ONNXRuntime and ML.NET
Install-Package Microsoft.ML.OnnxRuntime
Install-Package Microsoft.ML
Install-Package NAudio

🧑‍💻 Example Usage

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<VadSpeechSegment> 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:
    git clone https://github.com/your-username/VadSharp.git
  3. Create a new branch:
    git checkout -b feature-branch
  4. Make your changes & commit:
    git add .
    git commit -m "Your awesome feature!"
  5. Push the branch & create a PR:
    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.
  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 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

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages