You need a C99-compatible compiler to build these demos.
- The demo requires CMake version 3.13 or higher.
- For Windows Only: MinGW is required to build the demo.
Porcupine requires a valid Picovoice AccessKey
at initialization. AccessKey
acts as your credentials when using Porcupine SDKs.
You can get your AccessKey
for free. Make sure to keep your AccessKey
secret.
Signup or Login to Picovoice Console to get your AccessKey
.
cmake -S demo/c/. -B demo/c/build && cmake --build demo/c/build --target porcupine_demo_mic
cmake -S demo/c/. -B demo/c/build -G "MinGW Makefiles" && cmake --build demo/c/build --target porcupine_demo_mic
Running the executable without any commandline arguments prints the usage info to the console.
./demo/c/build/porcupine_demo_mic
Usage : ./demo/c/build/porcupine_demo_mic -l LIBRARY_PATH -m MODEL_PATH -k KEYWORD_PATH -t SENSITIVITY -a ACCESS_KEY -d AUDIO_DEVICE_INDEX
./demo/c/build/porcupine_demo_mic [-s, --show_audio_devices]
.\\demo\\c\\build\\porcupine_demo_mic.exe
Usage : .\\demo\\c\\build\\porcupine_demo_mic.exe -l LIBRARY_PATH -m MODEL_PATH -k KEYWORD_PATH -t SENSITIVITY -a ACCESS_KEY -d AUDIO_DEVICE_INDEX
.\\demo\\c\\build\\porcupine_demo_mic.exe [-s, --show_audio_devices]
The following commands shows the available audio input devices to the console.
./demo/c/build/porcupine_demo_mic --show_audio_devices
.\\demo\\c\\build\\porcupine_demo_mic.exe --show_audio_devices
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 and ${ACCESS_KEY}
with your AccessKey
.
./demo/c/build/porcupine_demo_mic \
-l lib/linux/x86_64/libpv_porcupine.so -m lib/common/porcupine_params.pv \
-k resources/keyword_files/linux/porcupine_linux.ppn -t 0.5 \
-a ${ACCESS_KEY} -d ${AUDIO_DEVICE_INDEX}
# Macos with Intel Chip
./demo/c/build/porcupine_demo_mic \
-l lib/mac/x86_64/libpv_porcupine.dylib -m lib/common/porcupine_params.pv \
-k resources/keyword_files/mac/porcupine_mac.ppn -t 0.5 \
-a ${ACCESS_KEY} -d ${AUDIO_DEVICE_INDEX}
# Macos with Apple Chip
./demo/c/build/porcupine_demo_mic \
-l lib/mac/arm64/libpv_porcupine.dylib -m lib/common/porcupine_params.pv \
-k resources/keyword_files/mac/porcupine_mac.ppn -t 0.5 \
-a ${ACCESS_KEY} -d ${AUDIO_DEVICE_INDEX}
Replace ${PROCESSOR}
with one of the Raspberry Pi processors defined here
(e.g., for Raspberry Pi 4 this would be "cortex-a72") and run:
./demo/c/build/porcupine_demo_mic \
-l lib/raspberry-pi/${PROCESSOR}/libpv_porcupine.so -m lib/common/porcupine_params.pv \
-k resources/keyword_files/raspberry-pi/porcupine_raspberry-pi.ppn -t 0.5 \
-a ${ACCESS_KEY} -d ${AUDIO_DEVICE_INDEX}
.\\demo\\c\\build\\porcupine_demo_mic.exe -l lib/windows/amd64/libpv_porcupine.dll -m lib/common/porcupine_params.pv -k resources/keyword_files/windows/porcupine_windows.ppn -t 0.5 -a ${ACCESS_KEY} -d ${AUDIO_DEVICE_INDEX}
cmake -S demo/c/. -B demo/c/build && cmake --build demo/c/build --target porcupine_demo_file
Running the executable without any commandline arguments prints the usage info to the console.
./demo/c/build/porcupine_demo_file
Usage : ./demo/c/build/porcupine_demo_file -l LIBRARY_PATH -m MODEL_PATH -k KEYWORD_PATH -t SENSITIVITY -a ACCESS_KEY -w WAV_PATH
.\\demo\\c\\build\\porcupine_demo_file.exe
Usage : .\\demo\\c\\build\\porcupine_demo_file.exe -l LIBRARY_PATH -m MODEL_PATH -k KEYWORD_PATH -t SENSITIVITY -a ACCESS_KEY -w WAV_PATH
Note that the demo expects a single-channel WAV file with a sampling rate of 16kHz and 16-bit linear PCM encoding.
Replace ${ACCESS_KEY}
with your AccessKey
.
./demo/c/build/porcupine_demo_file -l lib/linux/x86_64/libpv_porcupine.so -m lib/common/porcupine_params.pv \
-k resources/keyword_files/linux/americano_linux.ppn -t 0.5 -w resources/audio_samples/multiple_keywords.wav \
-a ${ACCESS_KEY}
# Macos with Intel Chip
./demo/c/build/porcupine_demo_file -l lib/mac/x86_64/libpv_porcupine.dylib -m lib/common/porcupine_params.pv \
-k resources/keyword_files/mac/americano_mac.ppn -t 0.5 -w resources/audio_samples/multiple_keywords.wav \
-a ${ACCESS_KEY}
# Macos with Apple Chip
./demo/c/build/porcupine_demo_file -l lib/mac/arm64/libpv_porcupine.dylib -m lib/common/porcupine_params.pv \
-k resources/keyword_files/mac/americano_mac.ppn -t 0.5 -w resources/audio_samples/multiple_keywords.wav \
-a ${ACCESS_KEY}
Replace ${PROCESSOR}
with one of the Raspberry Pi processors defined here
(e.g., for Raspberry Pi 4 this would be "cortex-a72") and run:
./demo/c/build/porcupine_demo_file -l lib/raspberry-pi/${PROCESSOR}/libpv_porcupine.so -m lib/common/porcupine_params.pv \
-k resources/keyword_files/raspberry-pi/americano_raspberry-pi.ppn -t 0.5 -w resources/audio_samples/multiple_keywords.wav \
-a ${ACCESS_KEY}
.\\demo\\c\\build\\porcupine_demo_file.exe -l lib/windows/amd64/libpv_porcupine.dll -m lib/common/porcupine_params.pv -k resources/keyword_files/windows/americano_windows.ppn -t 0.5 -w resources/audio_samples/multiple_keywords.wav -a ${ACCESS_KEY}