self-service. Developers are empowered to choose any wake word and build its model within seconds.

using deep neural networks trained in real-world situations.

compact and computationally-efficient making it suitable for IoT applications. It can run with as low as 20 KB of
RAM.

cross-platform. It is implemented in fixed-point ANSI C. Currently Raspberry Pi, Android, iOS,
watchOS, Linux, Mac, Windows, and web browsers are supported. Furthermore, Support for various
ARM Cortex-A and ARM Cortex-M processors and a growing number of DSPs is available.

scalable. It can detect tens of commands concurrently with no added CPU/memory footprint.

Try It Out

Try out Porcupine by downloading it's
Android demo application. The demo
application allows you to test Porcupine on a variety of wake words in any environment.

See Porcupine in action on an ARM Cortex-M7 (accompanied by Rhino for intent inference).

Getting Started

Wake Word Tutorial

Voice Control Tutorial

Performance

A comparison between accuracy and runtime metrics of Porcupine and two other widely-used libraries, PocketSphinx and
Snowboy, is provided here. Compared to the best-performing engine,
Porcupine's standard model is 2.53 times more accurate, 2.6 times faster (on Raspberry Pi 3), and consumes 45% less
memory.

Model Variants

Porcupine comes in two different variations: standard and tiny. The tiny model is specifically designed for
deeply-embedded applications. Its accuracy is slightly lower than the standard model but it consumes considerably less
resources. Below is the comparison of runtime measurements for different variants of Porcupine on Raspberry Pi3.

Structure of Repository

Porcupine is shipped as an ANSI C precompiled library. The binary files for supported platforms are located under
lib/ and header files are at include/. Currently, Raspberry Pi, Android, iOS, watchOS, Linux, Mac,
Windows, and modern web browsers are supported.

Bindings are available at binding/ to facilitate usage from higher-level languages/platforms. Demo
applications are at demo/. When possible, use one of the demo applications as a starting point for your own
implementation.

tools/ contains utility programs. Finally, resources/ is a placeholder for data used by
various applications within the repository.

Below is a quick walk-through of the repository. For detailed instructions please visit relevant pages. Throughout the
documentation, it is assumed that the current working directory is the root of the repository.

Running Demo Applications

Python Demo Application

This demo application allows testing Porcupine using computer's microphone. It opens an input audio
stream, monitors it using Porcupine's library, and logs the detection events into the console. Below is an example of
running the demo for hotword Alexa from the command line. Replace ${SYSTEM} with the name of the operating system
on your machine (e.g. linux, mac, windows, or raspberry-pi).

Android Demo Application

Using Android Studio open demo/android as an Android
project and then run the application. Note that you need an android phone with developer options enabled connected to
your machine in order to run the application.

iOS Demo Application

Using Xcode open demo/ios and run the application. Note that you need
an iOS device connected to your machine and a valid Apple developer account.

Creating Keyword Files

Porcupine enables developers to build models for any wake word. This is done using Porcupine's optimizer utility.
It finds optimal model hyper-parameters for a given hotword and stores these parameters in a keyword file.
You could create your own keyword file using the Porcupine's optimizer from the command line

In the above example replace ${SYSTEM} and ${TARGET_SYSTEM} with current and target (runtime) operating
systems (linux, mac, or windows). ${MACHINE} is the CPU architecture of current machine (x86_64 or i386). ${WAKE_WORD}
is the chosen wake word. Finally, ${OUTPUT_DIRECTORY} is the output directory where keyword file will be stored.

Integration

Below are code snippets showcasing how Porcupine can be integrated into different applications.

C

Porcupine is implemented in ANSI C and therefore can be directly linked to C applications.
include/pv_porcupine.h header file contains relevant information. An instance of Porcupine
object can be constructed as follows.

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

Now the handle can be used to monitor incoming audio stream. Porcupine accepts single channel, 16-bit PCM audio.
The sample rate can be retrieved using pv_sample_rate(). Finally, Porcupine accepts input audio in consecutive chunks
(aka frames) the length of each frame can be retrieved using pv_porcupine_frame_length().

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

When initialized, valid sample rate can be obtained using handle.sample_rate. Expected frame length
(number of audio samples in an input array) is handle.frame_length. The object can be used to monitor
incoming audio as below.

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

Now the instance can be used to monitor incoming audio stream. Porcupine accepts single channel, 16-bit PCM audio.
The sample rate can be retrieved using instance.SampleRate(). Finally, Porcupine accepts input audio in consecutive chunks
(aka frames) the length of each frame can be retrieved using instance.FrameLength().

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

Finally, be sure to explicitly release resources acquired by porcupine as the class does not rely on the garbage collector
for releasing native resources.

porcupine.delete();

High-Level API

Android demo application provides a high-level API for integrating Porcupine into Android applications.
The PorcupineManager class
manages all activities related to creating an input audio stream, feeding it into Porcupine's library, and
invoking a user-provided detection callback. The class can be initialized as below.

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

When initialized, input audio can be monitored using manager.start() . When done be sure to stop the manager using
manager.stop().

iOS

There are two approaches for integrating Porcupine into an iOS application.

Direct

Porcupine is shipped as a precompiled ANSI C library and can directly be used in Swift using module maps. It can be
initialized to detect multiple wake words concurrently using

Binding

PorcupineManager class manages all activities related to creating an input audio
stream, feeding it into Porcupine's library, and invoking a user-provided detection callback. The class can be
initialized as below

When initialized, input audio can be monitored using manager.startListening(). When done be sure to stop the manager using
manager.stopListening().

Javascript

Porcupine is available on modern web browsers in WebAssembly. The Javascript binding
makes it trivial use Porcupine within a Javascript environment. Instantiate a new instance of engine using the factory method
as below

v1.1.0 - April 11, 2018

v1.0.0 - March 13, 2018

Initial release.

License

This repository is licensed under Apache 2.0 except for the optimizer tool and keyword files
generated using it. This allows running the library on all supported platforms using the set of freely-available keyword
files.

Custom wake-words for Linux, Mac, and Windows can be generated using the optimizer tool only for
personal and non-commercial use. The use of optimizer tool and keyword files generated using it in
commercial products without acquiring a commercial licensing agreement from Picovoice is strictly prohibited.

Custom wake-words for other platforms are only provided with the purchase of the commercial license.