Rhino - Python API
This document outlines how to integrate Rhino Speech-to-Intent engine within an application using its Python API.
- Python 3
- Linux (x86_64)
- macOS (x86_64)
- Windows (x86_64)
- Raspberry Pi (all variants)
- NVIDIA Jetson (Nano)
pip3 install pvrhino
Create an instance of the engine:
import pvrhinohandle = pvrhino.create(context_path='/absolute/path/to/context')
context_path is the absolute path to Speech-to-Intent context created either using
Picovoice Console or one of the default contexts available on Rhino's GitHub repository.
The sensitivity of the engine can be tuned using the
sensitivity parameter. It is a floating point number within
[0, 1]. A higher sensitivity value results in fewer misses at the cost of (potentially) increasing the erroneous
import pvrhinohandle = pvrhino.create(context_path='/absolute/path/to/context', sensitivity=0.25)
When initialized, the valid sample rate is given by
handle.sample_rate. Expected frame length (number of audio samples
in an input array) is
handle.frame_length. The engine accepts 16-bit linearly-encoded PCM and operates on
def get_next_audio_frame():passwhile True:is_finalized = rhino.process(get_next_audio_frame())if is_finalized:inference = rhino.get_inference()if not inference.is_understood:# add code to handle unsupported commandspasselse:intent = inference.intentslots = inference.slots# add code to take action based on inferred intent and slot values
When done resources have to be released explicitly:
You can create custom Rhino context models using Picovoice Console.
In order to run inference on non-English contexts you need to use the corresponding model file. The model files for all supported languages are available here.