React Quick Start
- Chrome & Chromium-based browsers
- Picovoice Account and AccessKey
- Node.js 14+
- React 17.0+
Picovoice Account & AccessKey
Signup or Login to Picovoice Console to get your
Make sure to keep your
Leopard, you'll need a Leopard model file (
.pv). Place the model file in the project's public directory or generate a base64 representation of the file using the built-in script:
leopardModel object with either of the methods above:
Import and call the
useLeopard Hook, and initialize
Leopard with your
To process audio, you can either upload it as a
File object or record it directly. Once the audio has been processed, the transcript will be available in the
result state variable.
Transcribe File objects directly using the
Leopard React binding uses WebVoiceProcessor to record audio with a microphone. To start recording audio, call
stopRecording to stop recording audio and begin processing:
Once processing is complete, the transcript will be available via the
result state variable.
Allocated resources are automatically freed on unmount, but can also be done explicitly:
Create custom models using the Picovoice Console .
Train and download a Leopard speech-to-text model (
.pv) for the target platform
This model file can be used directly with
publicPath, but, if
base64 is preferable, convert the
.pv file to a base64
Model files (
.pv) are saved in IndexedDB to be used by Web Assembly.
publicPath must be set to instantiate Leopard.
If both are set, Leopard will use the
In order to use Leopard with other languages, you need to use the corresponding model file (
.pv) for the desired language. The model files for all
supported languages are available on the Leopard GitHub repository .
For the Leopard React SDK, there is a React demo project available on the Leopard GitHub repository .
Clone the Leopard repository from GitHub:
- 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.
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 Leopard. Once Leopard has loaded, upload an audio file or record audio with a microphone to begin transcribing speech-to-text.