Porcupine Wake Word
React Native Quick Start
Platforms
- Android (5.0+, API 21+)
- iOS (13.0+)
Requirements
- Picovoice Account and AccessKey
- React Native 0.62.2+
Picovoice Account & AccessKey
Signup or Login to Picovoice Console to get your AccessKey
.
Make sure to keep your AccessKey
secret.
Quick Start
Setup
Setup the React Native environment.
Install the npm packages:
- Enable the proper permission for recording with the hardware's microphone on both iOS and Android:
iOS
Open your Info.plist
and add the following line:
Android
Open your AndroidManifest.xml
and add the following line:
Usage
Create an instance of PorcupineManager
that detects the included built-in wake words porcupine
and bumblebee
:
Start audio capture and wake word detection with:
Stop with:
Free resources used by PorcupineManager
:
Custom Keywords
Create a custom keyword using the Picovoice Console. Download the custom wake word file (.ppn
) and add them to your platform projects:
Android custom models must be added to
./android/app/src/main/assets/
.iOS custom models can be added anywhere under
./ios
, but they must be included as a bundled resource in XCode by right-clicking on theNavigation tab
, and clickingAdd Files To ...
.
Create an instance of PorcupineManager
using the .fromKeywordPaths
constructor:
Keyword path arguments are relative to the platform-specific asset/resource directory.
Alternatively, if the keyword files are deployed to the device with a different method, the absolute paths to the files on device can be used.
Non-English Languages
Use the corresponding model file (.pv
), to detect non-English wake words.
The model files for all supported languages are available
on the Porcupine Wake Word GitHub repository.
Add the model file to your assets/resource directory and pass in the relative file path using the modelPath
argument:
Alternatively, if the model file is deployed to the device with a different method, the absolute path to the file on device can be used.
Demo
For the Porcupine Wake Word React Native SDK, there is a React Native demo project available on the Porcupine GitHub repository.
Setup
Clone the Porcupine Wake Word repository from GitHub:
Usage
- Install dependencies and setup environment:
- Connect a mobile device or launch a simulator. Then run the android-run or ios-run and replace
${LANGUAGE}
with the language code of your choice (e.g.de
-> German,ko
-> Korean). To see a list of available languages, command without a language code.
For more information on our Porcupine Wake Word demos for React Native, head over to our GitHub repository.
Resources
Packages
- @picovoice/porcupine-react-native on the npm registry
- @picovoice/react-native-voice-processor on the npm registry