csharpPicovoice Platform — .NET Quick Start

Platforms

  • Linux (x86_64)
  • macOS (x86_64)
  • Windows (x86_64)
  • BeagleBone
  • NVIDIA Jetson Nano
  • Raspberry Pi (2, 3, 4)

Requirements

.NET Framework 4.6.1+ / .NET Standard 2.0+ / .NET Core 3.1+:

  • Windows (x86_64)

.NET Core 2.0+ / .NET Core 3.1+:

  • Linux (x86_64)
  • macOS (x86_64)

.NET Core 3.1+:

  • BeagleBone
  • NVIDIA Jetson Nano
  • Raspberry Pi (2, 3, 4)

Picovoice Account & AccessKey

Signup or Login to Picovoice Console to get your AccessKey. Make sure to keep your AccessKey secret.

Quick Start

Setup

  1. Install .NET.

  2. Install the Picovoice NuGet package in Visual Studio or using the .NET CLI:

dotnet add package Picovoice

Usage

Create an instance of Picovoice that uses a Porcupine keyword file, and a Rhino context file:

using Pv;
void wakeWordCallback()
{
// wake word detected
}
void inferenceCallback(Inference inference)
{
if(inference.IsUnderstood)
{
string intent = inference.Intent;
Dictionary<string, string> slots = inference.Slots;
// take action based on inferred intent and slot values
}
else
{
// handle unsupported commands
}
}
Picovoice picovoice = Picovoice.Create(
"${ACCESS_KEY}",
"${KEYWORD_FILE_PATH}",
wakeWordCallback,
"${CONTEXT_FILE_PATH}",
inferenceCallback
);

Pass in frames of audio to the .process function:

short[] GetNextAudioFrame()
{
// ...
}
while(true)
{
picovoice.Process(GetNextAudioFrame());
}

Custom Wake Words & Contexts

Create custom contexts using the Picovoice Console. Download the custom Porcupine keyword (.ppn) and Rhino context (.rhn) files and create an instance of Picovoice using the Create method.

Non-English Languages

Use the corresponding model file (.pv) to process non-English wake words and contexts. The model files for all supported languages are available on the Porcupine and Rhino GitHub repositories.

Pass in the Porcupine model file using the porcupineModelPath input argument and the Rhino model file using the rhinoModelPath input argument to change the detection language:

Picovoice picovoice = Picovoice.Create(
${ACCESS_KEY},
"${KEYWORD_FILE_PATH}",
wakeWordCallback,
"${CONTEXT_FILE_PATH}",
inferenceCallback,
porcupineModelPath: "${PORCUPINE_MODEL_FILE_PATH}",
rhinoModelPath: ${RHINO_MODEL_FILE_PATH}
);

Demo

For the Picovoice .NET SDK, we offer demo applications that demonstrate how to use the end-to-end speech recognition engine on real-time audio streams (i.e. microphone input) and audio files.

Setup

  1. Clone the Picovoice repository from GitHub:
git clone --recurse-submodules https://github.com/Picovoice/picovoice.git
  1. Build the demo:
cd picovoice/demo/dotnet/PicovoiceDemo
dotnet build -c MicDemo.Release

Usage

Use the --help flag to see the usage options for the demo:

dotnet run -c MicDemo.Release -- --help

Ensure you have a working microphone connected to your system and run the following command to make inferences based on the given keyword and context files:

dotnet run -c MicDemo.Release -- --access_key ${ACCESS_KEY} --keyword_path ${KEYWORD_FILE_PATH} --context_path ${CONTEXT_FILE_PATH}

For more information on our Picovoice demos for .NET, head over to our GitHub repository.

Resources

Packages

API

GitHub

Benchmark

Further Reading

Videos


Issue with this doc? Please let us know.