Picovoice Platform
Flutter API
API Reference for the Picovoice Flutter SDK (pub.dev) .
Picovoice
Class for the Picovoice platform. Picovoice can be initialized either using the
High-level PicovoiceManager() Class or directly using the creator. Resources
should be cleaned when you are done using the delete()
function.
Picovoice.frameLength
Getter for the number of audio samples per frame required by Picovoice.
Picovoice.sampleRate
Getter for the audio sample rate required by Picovoice.
Picovoice.version
Getter for Picovoice version string.
Picovoice.porcupineVersion
Getter for the internal Porcupine version string.
Picovoice.rhinoVersion
Getter for the internal Rhino version string.
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.
Picovoice.create()
Static creator for initializing Picovoice.
Parameters
accessKey
String : AccessKey obtained from Picovoice Console.keywordPath
String : Path to keyword model file (.ppn
). Can be either a path that is relative to the project'sassets
folder or an absolute path to the file on device.wakeWordCallback
WakeWordCallback : User-defined callback invoked upon detection of the wake phrase. The callback accepts no input argumentscontextPath
String : Path to the Rhino context file (.rhn
). Can be either a path that is relative to the project'sassets
folder or an absolute path to the file on device.inferenceCallback
InferenceCallback : User-defined callback invoked upon completion of intent inference. The callback accepts a single input argument of typeRhinoInference
.porcupineSensitivity
double? : (Optional) Wake word detection sensitivity. It should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate.rhinoSensitivity
double? : (Optional) 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.porcupineModelPath
String? : (Optional) Path to the file containing Porcupine's model parameters (.pv
). Can be either a path that is relative to the project'sassets
folder or an absolute path to the file on device. If not set it will be set to the default location.rhinoModelPath
String? : (Optional) Path to the file containing Rhino's model parameters (.pv
). Can be either a path that is relative to the project'sassets
folder or an absolute path to the file on device. If not set it will be set to the default location. If not set it will be set to the default location.endpointDurationSec
double? : (Optional) 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? : (Optional) 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](#picovoice)
an instance of the Picovoice platform.
Throws
PicovoiceException
: If not initialized correctly.
Picovoice.process()
Processes a frame of the incoming audio stream. Upon detection of wake word and completion of follow-on command inference invokes user-defined callbacks.
Parameters
frame
List<int> : a frame of audio samples to be assessed by Picovoice. The required audio format is found by calling.sampleRate
to get the required sample rate and.frameLength
to get the required frame size. Audio must be single-channel and 16-bit linearly-encoded.
Throws
PicovoiceException
: If process fails.
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 process fails.
Picovoice.delete()
Release the resources acquired by Picovoice (via Porcupine and Rhino engines).
PicovoiceManager
Manager for creating an instance of Picovoice
. A High-level Flutter binding for Picovoice platform that
handles recording audio from microphone, processes it in real-time.
PicovoiceManager.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. Can only be accessed after a call to start()
PicovoiceManager.create()
Static creator for initializing Picovoice.
Parameters
accessKey
String : AccessKey obtained from Picovoice Console.keywordPath
String : Path to keyword model file (.ppn
). Can be either a path that is relative to the project'sassets
folder or an absolute path to the file on device.wakeWordCallback
WakeWordCallback : User-defined callback invoked upon detection of the wake phrase. The callback accepts no input argumentscontextPath
String : Path to the Rhino context file (.rhn
). Can be either a path that is relative to the project'sassets
folder or an absolute path to the file on device.inferenceCallback
InferenceCallback : User-defined callback invoked upon completion of intent inference. The callback accepts a single input argument of typeRhinoInference
.porcupineSensitivity
double? : (Optional) Wake word detection sensitivity. It should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate.rhinoSensitivity
double? : (Optional) 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.porcupineModelPath
String? : (Optional) Path to the file containing Porcupine's model parameters (.pv
). Can be either a path that is relative to the project'sassets
folder or an absolute path to the file on device. If not set it will be set to the default location.rhinoModelPath
String? : (Optional) Path to the file containing Rhino's model parameters (.pv
). Can be either a path that is relative to the project'sassets
folder or an absolute path to the file on device. If not set it will be set to the default location. If not set it will be set to the default location. set it will be set to the default location (.pv
).endpointDurationSec
double? : (Optional) 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? : (Optional) 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
ProcessErrorCallback : Reports errors that are encountered while the engine is processing audio.
Returns
PicovoiceManager
an instance of PicovoiceManager.
Throws
PicovoiceException
: If not initialized correctly.
PicovoiceManager.start()
Opens audio input stream and sends audio frames to Picovoice.
Throws
PicovoiceException
: If an error was encountered while starting audio processing.
PicovoiceManager.stop()
Closes audio stream and stops Picovoice processing.
Throws
PicovoiceException
: If an error was encountered while stopping audio processing.
PicovoiceManager.reset()
Resets the internal state of PicovoiceManager. It can be called to return to the wake word detection state before an inference has completed.
Throws
PicovoiceException
: If an error was encountered while resetting.
PicovoiceManager.delete()
Releases native resources that were allocated to PicovoiceManager.
ProcessErrorCallback
Type for the error callback that occurs while processing audio.
Parameters
- error
PicovoiceException
PicovoiceException
Exception thrown if an error occurs within Picovoice: