Rhino Speech-to-Intent
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
Request audio recording permissions from the user:
Create an instance of RhinoManager
that infers intent from spoken commands within a given context:
Once you have instantiated a RhinoManager, you can start audio capture and intent inference by calling:
When RhinoManager returns an inference result via the inferenceCallback
, it will automatically stop audio capture for you.
When you wish to result, call .process()
again.
Once your app is done with using RhinoManager, be sure you explicitly release the resources allocated for it:
Custom Contexts
Create a custom context using the Picovoice Console. Download the custom context file (.rhn
) and add it 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 context file is deployed to the device with a different method, the absolute path to the file 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 Rhino Speech-to-Intent GitHub repository.
Add the model file to your assets/resource directory and pass in the relative 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 Rhino Speech-to-Intent React Native SDK, there is a React Native demo project available on the Rhino GitHub repository.
Setup
Clone the Rhino Speech-to-Intent 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 Rhino Speech-to-Intent demos for React Native, head over to our GitHub repository.
Resources
Packages
- @picovoice/rhino-react-native on the npm registry
- @picovoice/react-native-voice-processor on the npm registry