#include <stdbool.h>
#include <stdint.h>
#include "picovoice.h"
Go to the source code of this file.
|
PV_API pv_status_t | pv_rhino_context_info (const pv_rhino_t *object, const char **context_info) |
|
PV_API void | pv_rhino_delete (pv_rhino_t *object) |
|
PV_API int32_t | pv_rhino_frame_length (void) |
|
PV_API pv_status_t | pv_rhino_free_slots_and_values (const pv_rhino_t *object, const char **slots, const char **values) |
|
PV_API pv_status_t | pv_rhino_get_intent (const pv_rhino_t *object, const char **intent, int32_t *num_slots, const char ***slots, const char ***values) |
|
PV_API pv_status_t | pv_rhino_init (const char *access_key, const char *model_path, const char *context_path, float sensitivity, bool require_endpoint, pv_rhino_t **object) |
|
PV_API pv_status_t | pv_rhino_is_understood (const pv_rhino_t *object, bool *is_understood) |
|
PV_API pv_status_t | pv_rhino_process (pv_rhino_t *object, const int16_t *pcm, bool *is_finalized) |
|
PV_API pv_status_t | pv_rhino_reset (pv_rhino_t *object) |
|
const PV_API char * | pv_rhino_version (void) |
|
◆ pv_rhino_t
Forward declaration for Rhino Speech-to-Intent engine. It directly infers the user's intent from spoken commands in real-time. Rhino processes incoming audio in consecutive frames and indicates if the inference is finalized. When finalized, the inferred intent can be retrieved as structured data in the form of an intent string and pairs of slots and values. The number of samples per frame can be attained by calling 'pv_rhino_frame_length()'. The incoming audio needs to have a sample rate equal to 'pv_sample_rate()' and be 16-bit linearly-encoded. Rhino operates on single-channel audio.
Definition at line 34 of file include/pv_rhino.h.
◆ pv_rhino_context_info()
Getter for context information.
- Parameters
-
| object | Speech-to-Intent object. |
[out] | context_info | Context information. |
- Returns
- Status code. Returns 'PV_STATUS_INVALID_ARGUMENT' on failure.
◆ pv_rhino_delete()
Destructor.
- Parameters
-
object | Speech-to-Intent object. |
◆ pv_rhino_frame_length()
PV_API int32_t pv_rhino_frame_length |
( |
void |
| ) |
|
Getter for number of audio samples per frame.
- Returns
- Frame length.
◆ pv_rhino_free_slots_and_values()
Frees memory resources allocated to slots and values after calling 'pv_rhino_get_intent()'. One shouldn't free these resources via standard C library 'free()'.
- Parameters
-
object | Speech-to-Intent object. |
slots | Slots. |
values | Slot values. |
- Returns
- Returns 'PV_STATUS_INVALID_ARGUMENT' on failure.
◆ pv_rhino_get_intent()
PV_API pv_status_t pv_rhino_get_intent |
( |
const pv_rhino_t * |
object, |
|
|
const char ** |
intent, |
|
|
int32_t * |
num_slots, |
|
|
const char *** |
slots, |
|
|
const char *** |
values |
|
) |
| |
Getter for the intent. The intent is stored as an intent string and pairs of slots and values. It should be called only after intent inference is finalized and it is verified that the spoken command is understood via calling 'pv_rhino_is_understood()'.
- Parameters
-
- Returns
- State code. Returns 'PV_STATUS_INVALID_ARGUMENT', 'PV_STATUS_INVALID_STATE', or 'PV_STATUS_OUT_OF_MEMORY' on failure.
◆ pv_rhino_init()
PV_API pv_status_t pv_rhino_init |
( |
const char * |
access_key, |
|
|
const char * |
model_path, |
|
|
const char * |
context_path, |
|
|
float |
sensitivity, |
|
|
bool |
require_endpoint, |
|
|
pv_rhino_t ** |
object |
|
) |
| |
Constructor.
- Parameters
-
| access_key | AccessKey obtained from Picovoice Console (https://console.picovoice.ai/). |
| model_path | Absolute path to file containing model parameters. |
| context_path | Absolute path to file containing context parameters. A context represents the set of expressions (spoken commands), intents, and intent arguments (slots) within a domain of interest. |
| sensitivity | Inference sensitivity. It should be a number within [0, 1]. A higher sensitivity value results in fewer misses at the cost of (potentially) increasing the erroneous inference rate. |
| require_endpoint | If set to true , Rhino requires an endpoint (chunk of silence) before finishing inference. |
[out] | object | Constructed Speech-to-Intent object. |
- Returns
- Status code. Returns 'PV_STATUS_INVALID_ARGUMENT', 'PV_STATUS_IO_ERROR', or 'PV_STATUS_OUT_OF_MEMORY' on failure.
◆ pv_rhino_is_understood()
Indicates if the spoken command is valid, is within the domain of interest (context), and the engine understood it. Upon success 'pv_rhino_get_intent()' may be called to retrieve inferred intent. If not understood, 'pv_rhino_reset()' should be called.
- Parameters
-
| object | Speech-to-Intent object. |
[out] | is_understood | Flag indicating if the spoken command is understood. |
- Returns
- Status code. Returns 'PV_STATUS_INVALID_ARGUMENT' on failure.
◆ pv_rhino_process()
Processes a frame of audio and emits a flag indicating if the inference is finalized. When finalized, 'pv_rhino_is_understood()' should be called to check if the spoken command is considered valid.
- Parameters
-
| object | Speech-to-Intent object. |
| pcm | A frame of audio samples. The number of samples per frame can be attained by calling 'pv_rhino_frame_length()'. The incoming audio needs to have a sample rate equal to 'pv_sample_rate()' and be 16-bit linearly-encoded. Rhino operates on single-channel audio. |
[out] | is_finalized | Flag indicating if the inference is finalized. |
- Returns
- Status code. Returns 'PV_STATUS_INVALID_ARGUMENT' or 'PV_STATUS_OUT_OF_MEMORY' on failure.
◆ pv_rhino_reset()
Resets the internal state of the engine. It should be called before the engine can be used to infer intent from a new stream of audio.
- Parameters
-
object | Speech-to-Intent object. |
- Returns
- Status code. Returns 'PV_STATUS_INVALID_ARGUMENT' on failure.
◆ pv_rhino_version()
const PV_API char* pv_rhino_version |
( |
void |
| ) |
|
Getter for version.
- Returns
- Version.