cPorcupine - C Quick Start

  • End-to-End Voice Platform
  • Offline Voice Recognition
  • Local Speech Recognition
  • Wake Word Detection
  • Raspberry Pi
  • BeagleBone
  • NVIDIA Jetson
  • Linux
  • macOS
  • Windows
  • C

Requirements

  • C99-compatible compiler
  • CMake 3.4 or higher
  • For Windows Only: MinGW is required to build the demo

Compatibility

  • Linux (x86_64)
  • macOS (x86_64)
  • Windows (x86_64)
  • Raspberry Pi (all variants)
  • NVIDIA Jetson (Nano)
  • BeagleBone

Setup

Cloning the Repository

If using SSH, clone the repository with:

git clone --recurse-submodules [email protected]:Picovoice/porcupine.git

If using HTTPS, then type

git clone --recurse-submodules https://github.com/Picovoice/porcupine.git

Microphone Demo

Build

First go to the root of the directory:

cd porcupine

Build the microphone demo:

cmake -S demo/c/. -B demo/c/build && cmake --build demo/c/build --target porcupine_demo_mic

List the available input devices by running the command below.

Linux, macOS, Raspberry Pi, BeagleBone, Jetson

./demo/c/build/porcupine_demo_mic --show_audio_devices

Windows

.\\demo\\c\\build\\porcupine_demo_mic.exe --show_audio_devices

Remember the index of your preferred audio device. We will refer this as ${AUDIO_DEVICE_INDEX} for the following instructions.

Run

The following commands start up a microphone audio stream and listens for the wake phrase "porcupine". Replace ${AUDIO_DEVICE_INDEX} with the index of the audio device.

Linux

./demo/c/build/porcupine_demo_mic lib/linux/x86_64/libpv_porcupine.so lib/common/porcupine_params.pv \
resources/keyword_files/linux/porcupine_linux.ppn 0.5 ${AUDIO_DEVICE_INDEX}

macOS

./demo/c/build/porcupine_demo_mic lib/mac/x86_64/libpv_porcupine.dylib lib/common/porcupine_params.pv \
resources/keyword_files/mac/porcupine_mac.ppn 0.5 ${AUDIO_DEVICE_INDEX}

Raspberry Pi

Replace ${CPU} in the command below based on the trim of Raspberry Pi (cortex-a72 for Raspberry Pi 4, cortex-a72-aarch64 for Raspberry Pi 4 8GB RAM, cortex-a53 for Raspberry Pi 3, cortex-a53-aarch64 for Raspberry Pi 3 8GB RAM, cortex-a7 for Raspberry Pi 2, and arm11 for the rest):

./demo/c/build/porcupine_demo_mic lib/raspberry-pi/${CPU}/libpv_porcupine.so lib/common/porcupine_params.pv \
resources/keyword_files/raspberry-pi/porcupine_raspberry-pi.ppn 0.5 ${AUDIO_DEVICE_INDEX}

BeagleBone

./demo/c/build/porcupine_demo_mic lib/beaglebone/libpv_porcupine.so lib/common/porcupine_params.pv \
resources/keyword_files/beaglebone/porcupine_beaglebone.ppn 0.5 ${AUDIO_DEVICE_INDEX}

Jetson

./demo/c/build/porcupine_demo_mic lib/jetson/cortex-a57-aarch64/libpv_porcupine.so lib/common/porcupine_params.pv \
resources/keyword_files/jetson/porcupine_jetson.ppn 0.5 ${AUDIO_DEVICE_INDEX}

Windows

.\\demo\\c\\build\\porcupine_demo_mic.exe lib/windows/amd64/libpv_porcupine.dll lib/common/porcupine_params.pv resources/keyword_files/windows/porcupine_windows.ppn 0.5 ${AUDIO_DEVICE_INDEX}

File Demo

Build

First go to the root of the directory:

cd porcupine

Build the microphone demo:

cmake -S demo/c/. -B demo/c/build && cmake --build demo/c/build --target porcupine_demo_file

Run

Linux

./demo/c/build/porcupine_demo_file lib/linux/x86_64/libpv_porcupine.so lib/common/porcupine_params.pv \
resources/keyword_files/linux/americano_linux.ppn 0.5 resources/audio_samples/multiple_keywords.wav

macOS

./demo/c/build/porcupine_demo_file lib/mac/x86_64/libpv_porcupine.dylib lib/common/porcupine_params.pv \
resources/keyword_files/mac/americano_mac.ppn 0.5 resources/audio_samples/multiple_keywords.wav

Raspberry Pi

Replace ${CPU} in the command below based on the trim of Raspberry Pi (cortex-a72 for Raspberry Pi 4, cortex-a72-aarch64 for Raspberry Pi 4 8GB RAM, cortex-a53 for Raspberry Pi 3, cortex-a53-aarch64 for Raspberry Pi 3 8GB RAM, cortex-a7 for Raspberry Pi 2, and arm11 for the rest):

./demo/c/build/porcupine_demo_file lib/raspberry-pi/${CPU}/libpv_porcupine.so lib/common/porcupine_params.pv \
resources/keyword_files/raspberry-pi/americano_raspberry-pi.ppn 0.5 resources/audio_samples/multiple_keywords.wav

BeagleBone

./demo/c/build/porcupine_demo_file lib/beaglebone/libpv_porcupine.so lib/common/porcupine_params.pv \
resources/keyword_files/beaglebone/americano_beaglebone.ppn 0.5 resources/audio_samples/multiple_keywords.wav

Jetson

./demo/c/build/porcupine_demo_file lib/jetson/cortex-a57-aarch64/libpv_porcupine.so lib/common/porcupine_params.pv \
resources/keyword_files/jetson/americano_jetson.ppn 0.5 resources/audio_samples/multiple_keywords.wav

Windows

.\\demo\\c\\build\\porcupine_demo_file.exe lib/windows/amd64/libpv_porcupine.dll lib/common/porcupine_params.pv resources/keyword_files/windows/americano_windows.ppn 0.5 resources/audio_samples/multiple_keywords.wav

Custom Wake Word

You can create custom Porcupine wake word models using Picovoice Console.


Issue with this doc? Please let us know.