Cobra 2.0.1

dotnet add package Cobra --version 2.0.1                
NuGet\Install-Package Cobra -Version 2.0.1                
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="Cobra" Version="2.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Cobra --version 2.0.1                
#r "nuget: Cobra, 2.0.1"                
#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.
// Install Cobra as a Cake Addin
#addin nuget:?package=Cobra&version=2.0.1

// Install Cobra as a Cake Tool
#tool nuget:?package=Cobra&version=2.0.1                

Cobra Binding for .NET

Cobra Voice Activity Detection Engine

Made in Vancouver, Canada by Picovoice

Cobra is an on-device streaming voice activity detection engine. Cobra is:

  • Private; All voice processing runs locally.
  • Accurate [1]
  • Cross-Platform:
    • Linux (x86_64), macOS (x86_64, arm64), and Windows (x86_64, arm64)
    • Android and iOS
    • Chrome, Safari, Firefox, and Edge
    • Raspberry Pi (3, 4, 5)

Requirements

  • .NET 8.0

Compatibility

Platform compatible with .NET Framework 4.6.1+:

  • Windows (x86_64)

Platforms compatible with .NET Core 2.0+:

  • macOS (x86_64)
  • Windows (x86_64)

Platform compatible with .NET 6.0+:

  • Raspberry Pi:

    • 3 (32 and 64 bit)
    • 4 (32 and 64 bit)
    • 5 (32 and 64 bit)
  • Linux (x86_64)

  • macOS (arm64)

  • Windows (arm64)

Installation

You can install the latest version of Cobra by getting the latest Cobra Nuget package in Visual Studio or using the .NET CLI.

dotnet add package Cobra

AccessKey

Cobra requires a valid Picovoice AccessKey at initialization. AccessKey acts as your credentials when using Cobra SDKs. You can get your AccessKey for free. Make sure to keep your AccessKey secret. Signup or Login to Picovoice Console to get your AccessKey.

Usage

Create an instance of the engine:

using Pv;

const string accessKey = "${ACCESS_KEY}"; // Obtained from the Picovoice Console (https://console.picovoice.ai/)

Cobra cobra = new Cobra(accessKey);

Replace ${AccessKey} with your AccessKey obtained from Picovoice Console. cobra is an instance of Cobra.

When initialized, the valid sample rate is given by cobra.SampleRate. Expected frame length (number of audio samples in an input array) is cobra.FrameLength. The engine accepts 16-bit linearly-encoded PCM and operates on single-channel audio.

Pass in frames of audio to get the probability of voice in each frame:

short[] GetNextAudioFrame()
{
    // .. get audioFrame
    return audioFrame;
}

while(true)
{
    float voiceProbability = cobra.Process(frame.ToArray());
    // .. use probability to trigger other functionality
}

Cobra will have its resources freed by the garbage collector, but to have resources freed immediately after use, wrap it in a using statement:

using(Cobra cobra = new Cobra(accessKey))
{
    // .. Cobra usage here
}

Demos

The Cobra dotnet demo project is a .NET command line application that allows for processing real-time audio (i.e. microphone) and files using Cobra.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 is compatible.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.0

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • 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
2.0.1 51 2/11/2025
2.0.0 86 2/4/2025