Picovoice Platform
Unity API
API Reference for the Picovoice Unity SDK.
package: Pv.Unity
Picovoice
Class for the Picovoice Platform.
Picovoice.ContextInfo
Gets the source of the Rhino context in YAML format. Shows the list of intents, which expressions map to those intents, as well as slots and their possible values.
Returns
string
: Rhino context source.
Picovoice.FrameLength
Gets the required number of audio samples-per-frame.
Returns
int
: Required frame length.
Picovoice.SampleRate
Get the audio sample rate required by Picovoice.
Returns
int
: Required sample rate in Hz.
Picovoice.PorcupineVersion
Gets the version number of the Porcupine library.
Returns
string
: Version of Porcupine.
Picovoice.RhinoVersion
Gets the version number of the Rhino library.
Returns
string
: Version of Rhino.
Picovoice.Version
Gets the version number of the Picovoice Platform.
Returns
string
: Version of Picovoice.
Picovoice.Create()
Factory method for creating instances of Picovoice
.
Parameters
accessKey
string : AccessKey obtained from Picovoice Console.keywordPath
string : Absolute path to Porcupine keyword file (.ppn).wakeWordCallback
Action : Function to be called once the wake word has been detected.contextPath
string : Absolute path to the Rhino context file (.rhn).inferenceCallback
Action<Inference> : Function to be called once Rhino has an inference ready.porcupineModelPath
float : Absolute path to the file containing Porcupine model parameters (.pv
). If not set, a default model is used.porcupineSensitivity
float : Sensitivity value for detecting keyword. The value should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate.rhinoModelPath
float : Absolute path to the file containing Rhino model parameters (.pv
). If not set, a default model is used.rhinoSensitivity
float : Inference sensitivity. A higher sensitivity value results in fewer misses at the cost of (potentially) increasing the erroneous inference rate. Sensitivity should be a floating-point number within [0, 1].endpointDurationSec
float : Endpoint duration in seconds. An endpoint is a chunk of silence at the end of an utterance that marks the end of spoken command. It should be a positive number within [0.5, 5]. A lower endpoint duration reduces delay and improves responsiveness. A higher endpoint duration assures Rhino doesn't return inference pre-emptively in case the user pauses before finishing the request.requireEndpoint
bool : If set totrue
, Rhino requires an endpoint (a chunk of silence) after the spoken command. If set tofalse
, Rhino tries to detect silence, but if it cannot, it still will provide inference regardless. Set tofalse
only if operating in an environment with overlapping speech (e.g. people talking in the background).
Returns
Picovoice
: An instance of the Picovoice Platform.
Throws
PicovoiceException
: If an error occurs while creating an instance of the Picovoice platform.
Picovoice.Dispose()
Explicitly releases resources acquired by Picovoice
.
Picovoice.Process()
Processes a frame of the incoming audio stream. Invokes user-defined callbacks upon detection of wake word and completion of follow-on command inference.
Parameters
pcm
short[] : A frame of audio samples.
Throws
PicovoiceException
: If there is an error while processing the audio frame.
Picovoice.Reset()
Resets the internal state of Picovoice. It should be called before processing a new stream of audio or when Picovoice was stopped while processing a stream of audio.
Throws
PicovoiceException
: If an error occurs while resetting.
PicovoiceException
Exception thrown if an error is encountered by the Picovoice
Platform.
Exceptions:
PicovoiceManager
High-level API for the Picovoice
Platform. It handles audio recording and processing in real-time,
and invokes the user-defined callbacks when the wake word is detected or when an inference is complete.
PicovoiceManager.IsAudioDeviceAvailable
Checks whether there are any audio capture devices available.
PicovoiceManager.IsRecording
Checks whether PicovoiceManager
is capturing audio or not.
Returns
bool
: If recording or not.
Returns
bool
: If any available audio capture device are available.
PicovoiceManager.Create()
Factory method for creating instances of PicovoiceManager
.
Parameters
accessKey
string : AccessKey obtained from Picovoice Console.keywordPath
string : Absolute path to Porcupine keyword file (.ppn).wakeWordCallback
Action : Function to be called once the wake word has been detected.contextPath
string : Absolute path to the Rhino context file (.rhn).inferenceCallback
Action<Inference> : Function to be called once Rhino has an inference ready.porcupineModelPath
float : Absolute path to the file containing Porcupine model parameters (.pv
). If not set, a default model is used.porcupineSensitivity
float : Sensitivity value for detecting keyword. The value should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate.rhinoModelPath
float : Absolute path to the file containing Rhino model parameters (.pv
). If not set, a default model is used.rhinoSensitivity
float : Inference sensitivity. A higher sensitivity value results in fewer misses at the cost of (potentially) increasing the erroneous inference rate. Sensitivity should be a floating-point number within [0, 1].endpointDurationSec
float : Endpoint duration in seconds. An endpoint is a chunk of silence at the end of an utterance that marks the end of spoken command. It should be a positive number within [0.5, 5]. A lower endpoint duration reduces delay and improves responsiveness. A higher endpoint duration assures Rhino doesn't return inference pre-emptively in case the user pauses before finishing the request.requireEndpoint
bool : If set totrue
, Rhino requires an endpoint (a chunk of silence) after the spoken command. If set tofalse
, Rhino tries to detect silence, but if it cannot, it still will provide inference regardless. Set tofalse
only if operating in an environment with overlapping speech (e.g. people talking in the background).processErrorCallback
Action<PicovoiceException> : A callback that reports errors that are encountered while the engine is processing audio.
Returns
PicovoiceManager
: An instance ofPicovoiceManager
.
Throws
PicovoiceException
: If an error occurs while creating an instance of the Picovoice platform.
PicovoiceManager.Delete()
Free resources that were allocated to PicovoiceManager
.
PicovoiceManager.Start()
Starts capturing audio and passing it to the Picovoice Platform.
Throws
PicovoiceException
: If an error occurs while starting audio capture.
PicovoiceManager.Stop()
Stops audio capture and processing.
Throws
PicovoiceException
: If an error occurs while stopping audio capture.
PicovoiceManager.Reset()
Resets the internal state of Picovoice. It should be called before processing a new stream of audio or when Picovoice was stopped while processing a stream of audio.
Throws
PicovoiceException
: If an error occurs while resetting.