unityPorcupine — Unity Quick Start

Platforms

  • Linux (x86_64)
  • macOS (x86_64, arm64)
  • Windows (x86_64)
  • Android 4.4+ (API 19+) (ARM only)
  • iOS 9.0+

Requirements

Picovoice Account & AccessKey

  1. Login or signup for a free account on the Picovoice Console.
  2. Go to the AccessKey tab to create one or use an existing AccessKey. Be sure to keep your AccessKey secret.

Quick Start

Setup

  1. Download and install Unity.
  2. Download and import the latest Porcupine Unity package.

NOTE: For running Porcupine on macOS arm64, use the porcupine-*-Apple-silicon.unitypackage version with Unity 2021.2+.

Usage

Create an instance of PorcupineManager that detects the included built-in wake words porcupine and bumblebee using the FromBuiltInKeywords constructor:

using Pv.Unity;
void wakeWordCallback(int keywordIndex)
{
if(keywordIndex == 0)
{
// `porcupine` detected
}
else if (keywordIndex == 1)
{
// `bumblebee` detected
}
}
PorcupineManager porcupineManager = PorcupineManager.FromBuiltInKeywords(
"${ACCESS_KEY}",
new List<Porucpine.BuiltInKeyword>
{
Porcupine.BuiltInKeyword.PORCUPINE,
Porcupine.BuiltInKeyword.BUMBLEBEE
},
wakeWordCallback);

Start audio capture and wake word detection with:

porcupineManager.Start();

Stop with:

porcupineManager.Stop();

Release resources acquired by PorcupineManager with:

porcupineManager.Delete();

Custom Keywords

Create custom keywords using the Picovoice Console. Download the custom wake word file (.ppn) and create an instance of PorcupineManager using the FromKeywordPaths constructor:

PorcupineManager porcupineManager = PorcupineManager.FromKeywordPaths(
"${ACCESS_KEY}",
new List<string> {"${KEYWORD_FILE_PATH}"});

Non-English Languages

Use the corresponding model file (.pv), to detect non-English wake words. The model files for all supported languages are available on the Porcupine GitHub repository.

Pass in the model file using the modelPath input argument to change the detection language:

PorcupineManager porcupineManager = PorcupineManager.FromKeywordPaths(
"${ACCESS_KEY}",
new List<string> {"${KEYWORD_FILE_PATH}"},
modelPath: "${MODEL_FILE_PATH}");

Demo

For the Porcupine Unity SDK, we offer demo applications that demonstrate how to use the Wake Word engine on real-time audio streams (i.e. microphone input).

Setup

Download and import the latest Porcupine Unity package.

Usage

  1. Open the Porcupine Demo Scene (Porcupine/PorcupineDemo/PorcupineDemo.unity).
  2. Copy AccessKey from Picovoice Console into the ACCESS_KEY variable in PorcupineDemo.cs
  3. Play the scene in the editor or go to File > Build Settings and click the Build and Run button to compile and run the scene for the selected platform.

Resources

Packages

API

GitHub

Benchmark

Further Reading

Videos


Issue with this doc? Please let us know.