cPicovoice Platform — C Quick Start

  • End-to-End Voice Platform
  • Offline Voice Recognition
  • Local Speech Recognition
  • Speech-to-Intent
  • Domain-Specific NLU
  • Wake Word Detection
  • Raspberry Pi
  • BeagleBone
  • 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)
  • BeagleBone

Setup

Cloning the Repository

If using SSH, clone the repository with:

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

If using HTTPS, then type

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

Microphone Demo

Build

First go to the root of the directory:

cd picovoice

Build the microphone demo:

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

List the available input devices by running the command below.

Linux, macOS, Raspberry Pi, BeagleBone

./demo/c/build/picovoice_demo_mic --show_audio_devices

Windows

.\\demo\\c\\build\\picovoice_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 steam and will wait for the "Picovoice" wake word phrase. Replace ${AUDIO_DEVICE_INDEX} with the index of the audio device.

Linux

./demo/c/build/picovoice_demo_mic \
sdk/c/lib/linux/x86_64/libpicovoice.so \
resources/porcupine/lib/common/porcupine_params.pv \
resources/porcupine/resources/keyword_files/linux/picovoice_linux.ppn \
0.5 \
resources/rhino/lib/common/rhino_params.pv \
resources/rhino/resources/contexts/linux/smart_lighting_linux.rhn \
0.5 \
{AUDIO_DEVICE_INDEX}

macOS

./demo/c/build/picovoice_demo_mic \
sdk/c/lib/mac/x86_64/libpicovoice.dylib \
resources/porcupine/lib/common/porcupine_params.pv \
resources/porcupine/resources/keyword_files/mac/picovoice_mac.ppn \
0.5 \
resources/rhino/lib/common/rhino_params.pv \
resources/rhino/resources/contexts/mac/smart_lighting_mac.rhn \
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-a53 for Raspberry Pi 3, cortex-a7 for Raspberry Pi 2, and arm11 for the rest):

./demo/c/build/picovoice_demo_mic \
sdk/c/lib/raspberry-pi/${CPU}/libpicovoice.so \
resources/porcupine/lib/common/porcupine_params.pv \
resources/porcupine/resources/keyword_files/raspberry-pi/picovoice_raspberry-pi.ppn \
0.5 \
resources/rhino/lib/common/rhino_params.pv \
resources/rhino/resources/contexts/raspberry-pi/smart_lighting_raspberry-pi.rhn \
0.5 \
{AUDIO_DEVICE_INDEX}

BeagleBone

./demo/c/build/picovoice_demo_mic \
sdk/c/lib/beaglebone/libpicovoice.so \
resources/porcupine/lib/common/porcupine_params.pv \
resources/porcupine/resources/keyword_files/beaglebone/picovoice_beaglebone.ppn \
0.5 \
resources/rhino/lib/common/rhino_params.pv \
resources/rhino/resources/contexts/beaglebone/smart_lighting_beaglebone.rhn \
0.5 \
{AUDIO_DEVICE_INDEX}

Windows

.\\demo\\c\\build\\picovoice_demo_mic.exe sdk/c/lib/windows/amd64/libpicovoice.dll resources/porcupine/lib/common/porcupine_params.pv resources/porcupine/resources/keyword_files/windows/picovoice_windows.ppn 0.5 resources/rhino/lib/common/rhino_params.pv resources/rhino/resources/contexts/windows/smart_lighting_windows.rhn 0.5 {AUDIO_DEVICE_INDEX}

Once the wake word is detected, the following prints to console:

[wake word]

After the wake word is detected, you may say follow-on voice commands (in the context of smart lighting). For example:

"Turn on the lights."

If understood correctly, the following prints to the console:

{
is_understood : 'true',
intent : 'changeLightState',
slots : {
'state' : 'on',
}
}

File Demo

Build

First go to the root of the directory:

cd picovoice

Build the file demo:

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

Run

The following processes a WAV file under the audio_samples directory (located under ./resources/). It detects the wake word and infers the intent in the context of a coffee maker system.

Linux

./demo/c/build/picovoice_demo_file \
sdk/c/lib/linux/x86_64/libpicovoice.so \
resources/porcupine/lib/common/porcupine_params.pv \
resources/porcupine/resources/keyword_files/linux/picovoice_linux.ppn \
0.5 \
resources/rhino/lib/common/rhino_params.pv \
resources/rhino/resources/contexts/linux/coffee_maker_linux.rhn \
0.5 \
resources/audio_samples/picovoice-coffee.wav

macOS

./demo/c/build/picovoice_demo_file \
sdk/c/lib/mac/x86_64/libpicovoice.dylib \
resources/porcupine/lib/common/porcupine_params.pv \
resources/porcupine/resources/keyword_files/mac/picovoice_mac.ppn \
0.5 \
resources/rhino/lib/common/rhino_params.pv \
resources/rhino/resources/contexts/mac/coffee_maker_mac.rhn \
0.5 \
resources/audio_samples/picovoice-coffee.wav

Raspberry Pi

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

./demo/c/build/picovoice_demo_file \
sdk/c/lib/raspberry-pi/${CPU}/libpicovoice.so \
resources/porcupine/lib/common/porcupine_params.pv \
resources/porcupine/resources/keyword_files/raspberry-pi/picovoice_raspberry-pi.ppn \
0.5 \
resources/rhino/lib/common/rhino_params.pv \
resources/rhino/resources/contexts/raspberry-pi/coffee_maker_raspberry-pi.rhn \
0.5 \
resources/audio_samples/picovoice-coffee.wav

BeagleBone

./demo/c/build/picovoice_demo_file \
sdk/c/lib/beaglebone/libpicovoice.so \
resources/porcupine/lib/common/porcupine_params.pv \
resources/porcupine/resources/keyword_files/beaglebone/picovoice_beaglebone.ppn \
0.5 \
resources/rhino/lib/common/rhino_params.pv \
resources/rhino/resources/contexts/beaglebone/coffee_maker_beaglebone.rhn \
0.5 \
resources/audio_samples/picovoice-coffee.wav

Windows

.\\demo\\c\\build\\picovoice_demo_file.exe sdk/c/lib/windows/amd64/libpicovoice.dll resources/porcupine/lib/common/porcupine_params.pv resources/porcupine/resources/keyword_files/windows/picovoice_windows.ppn 0.5 resources/rhino/lib/common/rhino_params.pv resources/rhino/resources/contexts/windows/coffee_maker_windows.rhn 0.5 resources/audio_samples/picovoice-coffee.wav

The following prints to the console:

[wake word]
{
is_understood : 'true',
intent : 'orderBeverage',
slots : {
'size' : 'large',
'beverage' : 'coffee',
}
}
real time factor : 0.006

Create Custom Wake Words & Contexts

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


Issue with this doc? Please let us know.