Made in Vancouver, Canada by Picovoice
Porcupine is a highly-accurate and lightweight wake word engine. It enables building always-listening voice-enabled applications. It 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.
- LibPrintf
The Porcupine SDK requires a valid AccessKey
at initialization. AccessKey
s 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
:
- Login or Signup for a free account on the Picovoice Console.
- Once logged in, go to the
AccessKey
tab to create one or use an existingAccessKey
.
- define all the necessary variables before
setup()
:
#include <Porcupine_EN.h>
#define MEMORY_BUFFER_SIZE ...
static uint8_t memory_buffer[MEMORY_BUFFER_SIZE] __attribute__((aligned(16));
static const char* ACCESS_KEY = ...; //AccessKey string obtained from [Picovoice Console](https://picovoice.ai/console/)
const uint8_t keyword_array[] = {...};
const int32_t keyword_model_sizes = sizeof(keyword_array);
const void *keyword_models = keyword_array;
static const float SENSITIVITY = 0.75f;
pv_porcupine_t *handle = NULL;
Sensitivity is the parameter that enables developers to trade miss rate for false alarm. It is a floating-point number within [0, 1]. A higher sensitivity reduces miss rate (false reject rate) at cost of increased false alarm rate.
handle
is an instance of Porcupine runtime engine that detects utterances of wake phrase defined in keyword_array
.
- put the following code block inside
setup()
in order to initialize the Picovoice engine:
const pv_status_t status = pv_porcupine_init(
ACCESS_KEY,
MEMORY_BUFFER_SIZE,
memory_buffer,
1,
&keyword_model_sizes,
&keyword_models,
&SENSITIVITY,
&handle);
if (status != PV_STATUS_SUCCESS) {
// error handling logic
}
Picovoice accepts single channel, 16-bit PCM audio. The sample rate can be retrieved using pv_sample_rate()
. Picovoice accepts input audio in consecutive chunks (aka frames); the length of each frame can be retrieved using pv_porcupine_frame_length()
. Inside the loop()
function in the sketch, pass the recorded audio to the Picovoice engine:
const int16_t *pcm = pv_audio_rec_get_new_buffer()
int32_t keyword_index;
const pv_status_t status = pv_porcupine_process(handle, pcm, &keyword_index);
if (status != PV_STATUS_SUCCESS) {
// error handling logic
}
if (keyword_index != -1) {
// detection event logic/callback
}
- Compile and upload the
Porcupine_EN/GetUUID
sketch from theFile -> Examples
menu. Copy the UUID of the board printed at the beginning of the session to the serial monitor. - Go to Picovoice Console to create models for Porcupine wake word engine.
- Select
Arm Cortex M
as the platform when training the model. - Select your board type (
Arduino Nano 33 BLE Sense
) and provide the UUID of the chipset on the board.
The model is now being trained. You will be able to download it within a few hours.
- Download your custom voice model(s) from Picovoice Console.
- Decompress the zip file. The model for Porcupine wake word is located in two files: A binary
.ppn
file, and as a.h
header file containing aC
array version of the binary model. - Copy the contents of the array inside the
.h
header file and update update theDEFAULT_KEYWORD_ARRAY
values inparams.h
.