Porcupine 2.0.1

.NET Core 3.1 .NET Standard 2.0
There is a newer version of this package available.
See the version list below for details.
NuGet\Install-Package Porcupine -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.
dotnet add package Porcupine --version 2.0.1
<PackageReference Include="Porcupine" Version="2.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Porcupine --version 2.0.1
#r "nuget: Porcupine, 2.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Porcupine as a Cake Addin
#addin nuget:?package=Porcupine&version=2.0.1

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

Porcupine Binding for .NET

Porcupine Wake Word Engine

Made in Vancouver, Canada by Picovoice

Porcupine is a highly-accurate and lightweight wake word engine. It enables building always-listening voice-enabled applications.

Porcupine is:

  • using deep neural networks trained in real-world environments.
  • compact and computationally-efficient. It is perfect for IoT.
  • scalable. It can detect multiple always-listening voice commands with no added runtime footprint.
  • self-service. Developers can train custom wake word models using Picovoice Console.

Requirements

  • .NET Core 3.1

Compatibility

Platform compatible with .NET Framework 4.6.1+:

  • Windows (x86_64)

Platforms compatible with .NET Core 2.0+:

  • Linux (x86_64)
  • macOS (x86_64)
  • Windows (x86_64)

Platforms compatible with .NET Core 3.1+:

  • Raspberry Pi:
    • 2
    • 3 (32 and 64 bit)
    • 4 (32 and 64 bit)
  • NVIDIA Jetson Nano
  • BeagleBone

Installation

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

dotnet add package Porcupine

AccessKey

Porcupine requires a valid Picovoice AccessKey at initialization. AccessKeys act as your credentials when using Porcupine SDKs. You can create your AccessKey for free. Make sure to keep your AccessKey secret.

To obtain your AccessKey:

  1. Login or Signup for a free account on the Picovoice Console.
  2. Once logged in, go to the AccessKey tab to create one or use an existing AccessKey.

Usage

Create an instance of the engine:

using Pv;

const string accessKey = "${ACCESS_KEY}";
var keyword = new List<BuiltInKeyword> { BuiltInKeyword.PICOVOICE };

Porcupine handle = Porcupine.FromBuiltInKeywords(accessKey, keyword);

handle is an instance of Porcupine that detects utterances of "Picovoice". Using the FromBuiltInKeywords constructor allows you to initialize the Porcupine engine to detect any of the free, built-in keywords that come with the library. These built-ins are represented by the BuiltInKeyword enum.

Porcupine can detect multiple keywords concurrently:

const string accessKey = "${ACCESS_KEY}";
var keywords = new List<BuiltInKeyword> { 
        BuiltInKeyword.BUMBLEBEE,
        BuiltInKeyword.PICOVOICE 
    };

Porcupine handle = Porcupine.FromBuiltInKeywords(accessKey, keywords);

To detect custom keywords, use the FromKeywordPaths constructor instead:

const string accessKey = "${ACCESS_KEY}";
var keywordPaths = new List<string> { 
    "/absolute/path/to/keyword/one", 
    "/absolute/path/to/keyword/two", 
    ... }

Porcupine handle = Porcupine.FromKeywordPaths(accessKey, keywordPaths);

In addition to custom keywords, you can override the default Porcupine english model file and/or keyword sensitivities.

Sensitivity is the parameter that enables trading miss rate for the false alarm rate. It is a floating-point number within [0, 1]. A higher sensitivity reduces the miss rate at the cost of increased false alarm rate.

The model file contains the parameters for the wake word engine. To change the language that Porcupine understands, you'll pass in a different model file.

const string accessKey = "${ACCESS_KEY}";
var keywords = new List<BuiltInKeyword> { 
        BuiltInKeyword.GRAPEFRUIT,
        BuiltInKeyword.PORCUPINE 
    };
string modelPath = "/path/to/model.pv"
var sensitivities = new List<float>{ 0.6f, 0.35f };

Porcupine handle = Porcupine.FromBuiltInKeywords(
    accessKey,
    keywords,
    modelPath: modelPath,
    sensitivities: sensitivities);

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

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

while(true)
{
    var keywordIndex = handle.Process(GetNextAudioFrame());
    if(keywordIndex >= 0)
    {
	    // .. detection event logic/callback
    }
}

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

using(Porcupine handle = Porcupine.FromBuiltInKeywords(
    accessKey, 
    new List<BuiltInKeyword> { BuiltInKeyword.PICOVOICE }))
{
    // .. Porcupine usage here
}

Non-English Wake Words

In order to detect non-English wake words you need to use the corresponding model file. The model files for all supported languages are available here.

Demos

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

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Porcupine:

Package Downloads
Picovoice

Picovoice is an end-to-end platform for building voice products on your terms. It enables creating voice experiences similar to Alexa and Google. But it entirely runs 100% on-device. Picovoice is: - Private: Everything is processed offline. Intrinsically HIPAA and GDPR compliant. - Reliable: Runs without needing constant connectivity. - Zero Latency: Edge-first architecture eliminates unpredictable network delay. - Accurate: Resilient to noise and reverberation. It outperforms cloud-based alternatives by wide margins *. - Cross-Platform: Design once, deploy anywhere. Build using familiar languages and frameworks.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.5 552 6/29/2022
2.1.4 320 6/13/2022
2.1.3 301 5/16/2022
2.1.2 267 3/11/2022
2.1.1 319 2/3/2022
2.1.0 230 1/19/2022
2.0.1 263 11/30/2021
1.9.4 339 9/3/2021
1.9.3 859 5/11/2021
1.9.0 655 12/2/2020
1.8.9 380 10/21/2020