Rhino Speech-to-Intent
React Quick Start
Platforms
- Chrome & Chromium-based browsers
- Edge
- Firefox
- Safari
Requirements
- Picovoice Account and AccessKey
- Node.js 16+
- React 17+
- npm
Picovoice Account & AccessKey
Signup or login to Picovoice Console to get your AccessKey.
Make sure to keep your AccessKey secret.
Quick Start
Setup
Install Node.js.
Install the npm packages:
Usage
To initialize Rhino Speech-to-Intent, you'll need a context file (.rhn) as well as a
model file (.pv). Place these files in the project's
public directory or generate base64 representations of the files using the built-in script:
Create a rhinoContext and a rhinoModel object with either of the methods above:
Import and call the useRhino Hook, and initialize Rhino Speech-to-Intent with your AccessKey, rhinoContext, and rhinoModel:
To start detecting for an inference, run the process function:
The process function initializes WebVoiceProcessor.
Rhino Speech-to-Intent will then listen and process frames of microphone audio until it reaches a conclusion, then return the result via the inference variable.
Once a conclusion is reached, Rhino will enter a paused state. From the paused state, process will need to be called again to detect another inference.
Allocated resources are automatically freed on unmount, but can also be done explicitly:
Custom Contexts
Create custom contexts in the Picovoice Console using
the Rhino Speech-to-Intent Grammar. Train and download a Rhino context file (.rhn) for the target platform Web (WASM). This model file can be used directly with publicPath, but, if base64 is preferable, convert the .rhn file to a base64
JavaScript variable using the built-in pvbase64 script:
Similar to the model file (.pv), context files (.rhn) are saved in IndexedDB to be used by Web Assembly. Either base64 or publicPath must be set for the context to instantiate Rhino.
If both are set, Rhino Speech-to-Intent will use the base64 model.
Non-English Languages
In order to use Rhino Speech-to-Intent with different languages you need to use the corresponding model file (.pv) for the desired language.
The model files for all supported languages are available in the Rhino GitHub repository.
Demo
For the Rhino Speech-to-Intent React SDK, there is a React demo project available on the Rhino GitHub repository.
Setup
Clone the Rhino Speech-to-Intent repository from GitHub:
Usage
- Install dependencies:
- Run the demo with the
startscript with a language code to start a local web server hosting the demo in the language of your choice (e.g.de-> German,ko-> Korean). To see a list of available languages, run start without a language code.
Open http://localhost:3000 to view it in the browser.
Enter your access key and press on
Init Rhinoto start the demo.