Skip to main content

Rhino Speech-to-Intent engine.

Project description

Rhino Speech-to-Intent Engine

Made in Vancouver, Canada by Picovoice

Rhino is Picovoice's Speech-to-Intent engine. It directly infers intent from spoken commands within a given context of interest, in real-time. For example, given a spoken command:

Can I have a small double-shot espresso?

Rhino infers that the user would like to order a drink and emits the following inference result:

{
  "isUnderstood": "true",
  "intent": "orderBeverage",
  "slots": {
    "beverage": "espresso",
    "size": "small",
    "numberOfShots": "2"
  }
}

Rhino is:

  • using deep neural networks trained in real-world environments.
  • compact and computationally-efficient, making it perfect for IoT.
  • self-service. Developers and designers can train custom models using Picovoice Console.

Compatibility

  • Python 3.9+
  • Runs on Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64, arm64), and Raspberry Pi (Zero, 3, 4, 5).

Installation

pip3 install pvrhino

AccessKey

Rhino requires a valid Picovoice AccessKey at initialization. AccessKey acts as your credentials when using Rhino SDKs. You can get your AccessKey for free. Make sure to keep your AccessKey secret. Signup or Login to Picovoice Console to get your AccessKey.

Usage

Create an instance of the engine:

import pvrhino

access_key = "${ACCESS_KEY}" # AccessKey obtained from Picovoice Console (https://console.picovoice.ai/)

handle = pvrhino.create(access_key=access_key, context_path='/absolute/path/to/context')

Where 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 inference rate.

import pvrhino

access_key = "${ACCESS_KEY}" # AccessKey obtained from Picovoice Console (https://console.picovoice.ai/)

handle = pvrhino.create(access_key=access_key, 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 single-channel audio.

def get_next_audio_frame():
    pass

while 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 commands
            pass
        else:
            intent = inference.intent
            slots = inference.slots
            # add code to take action based on inferred intent and slot values

When done resources have to be released explicitly:

handle.delete()

Non-English Contexts

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.

Train Models over API

You can train models over API without going to the console:

train_context_from_dynamic_slots(
        "${ACCESS_KEY}",                             # AccessKey obtained from Picovoice Console (https://console.picovoice.ai/)
        "${OUTPUT_PATH}",                            # Path to save the newly trained model
        "${LANGUAGE}",                               # Two-character language code
        "${CONTEXT_PATH}",                           # Path to Rhino's context (.rhn) file
        {"${SLOT_NAME}": {"${SLOT1}", "${SLOT2}"}},  # Dynamic slot key-value pairs to merge into the YAML's `context.slots` section.
        "${PLATFORM}"                                # Optional platform for the trained model. If None, the default(current) platform is used.

(or)

train_context_from_yaml(
        "${ACCESS_KEY}",                             # AccessKey obtained from Picovoice Console (https://console.picovoice.ai/)
        "${OUTPUT_PATH}",                            # Path to save the newly trained model
        "${LANGUAGE}",                               # Two-character language code
        "${YAML_PATH}",                              # Path to YAML configuration file
        "${PLATFORM}"                                # Optional platform for the trained model. If None, the default(current) platform is used.

train_context_from_dynamic_slots is better suited if you would like the add additional slot values to your current Rhino model.

Check Rhino Model API docs for a list of supported languages and platforms.

Demos

pvrhinodemo provides command-line utilities for processing real-time audio (i.e. microphone) and files using Rhino.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pvrhino-4.0.3.tar.gz (4.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pvrhino-4.0.3-py3-none-any.whl (4.3 MB view details)

Uploaded Python 3

File details

Details for the file pvrhino-4.0.3.tar.gz.

File metadata

  • Download URL: pvrhino-4.0.3.tar.gz
  • Upload date:
  • Size: 4.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pvrhino-4.0.3.tar.gz
Algorithm Hash digest
SHA256 2f15d7687adba90d79535a331335d9e4266994f84de8688fa061d0eb5a916d3e
MD5 2ab62d63e85532055e46d001d8da64f4
BLAKE2b-256 e0a282c4a411651bd2580fe93c385180326509b9a56a116ce60f494c189c832d

See more details on using hashes here.

File details

Details for the file pvrhino-4.0.3-py3-none-any.whl.

File metadata

  • Download URL: pvrhino-4.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pvrhino-4.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fbf515212d4e6abf2e02fbd238230687670f0d518382aa25b1ae962b9c396b20
MD5 9dac04c5dfe2f42f648c58c4dc3fb082
BLAKE2b-256 45e41c8e58e9322c11287dfcbc4d5dfd7704425aebd71121127cc5acb37160d3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page