Picovoice Platform
React Native Quick Start
Platforms
- Android (5.0+, API 21+)
- iOS (13.0+)
Requirements
- Picovoice Account and AccessKey
- React Native 0.63+
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 PicovoiceManager
using a Porcupine keyword file (.ppn
), and a Rhino context file (.rhn
):
Start audio capture and processing with:
Stop with:
Free resources used by PicovoiceManager
:
Custom Wake Words & Contexts
Create custom keywords and contexts using the Picovoice Console. Download the custom models (.ppn
and .rhn
) and add them to the 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 ...
.
Alternatively, if the model 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 files (.pv
) to detect non-English wake words.
The model files for all supported languages are available on the Porcupine GitHub repository and the Rhino GitHub repository.
Add the model files to your assets/resource directory and pass in the relative paths using the porcupineModelPath
and rhinoModelPath
arguments:
Alternatively, if the model files are deployed to the device with a different method, the absolute paths to the files on device can be used.
Demo
For the Picovoice React Native SDK, there is a React Native demo project available on the Picovoice GitHub repository.
Setup
Clone the Picovoice 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 Picovoice demos for React Native, head over to our GitHub repository.
Resources
Packages
- @picovoice/picovoice-react-native on the npm registry
- @picovoice/porcupine-react-native on the npm registry
- @picovoice/rhino-react-native on the npm registry
- @picovoice/react-native-voice-processor on the npm registry