flutterPicovoice Platform - Flutter API

API Reference for the Picovoice Flutter SDK (pub.dev) .


Picovoice

class 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

int get frameLength

Getter for the number of audio samples per frame required by Picovoice.


Picovoice.sampleRate

int get sampleRate

Getter for the audio sample rate required by Picovoice.


Picovoice.version

String get version

Getter for Picovoice version string.


Picovoice.porcupineVersion

String get porcupineVersion

Getter for the internal Porcupine version string.


Picovoice.rhinoVersion

String get rhinoVersion

Getter for the internal Rhino version string.


Picovoice.contextInfo

String? get 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.

static create(
String accessKey,
String keywordPath,
WakeWordCallback wakeWordCallback,
String contextPath,
InferenceCallback inferenceCallback,
{double porcupineSensitivity = 0.5,
double rhinoSensitivity = 0.5,
String? porcupineModelPath,
String? rhinoModelPath,
bool requireEndpoint = true})

Parameters

  • accessKey String : AccessKey obtained from Picovoice Console.
  • keywordPath String : A List of absolute paths to keyword model file (.ppn).
  • wakeWordCallback WakeWordCallback : User-defined callback invoked upon detection of the wake phrase. The callback accepts no input arguments
  • contextPath String : Absolute path to the Rhino context file (.rhn).
  • inferenceCallback InferenceCallback : User-defined callback invoked upon completion of intent inference. The callback accepts a single input argument of type RhinoInference.
  • 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) Absolute path to the file containing Porcupine's model parameters. If not set it will be set to the default location (.pv).
  • rhinoModelPath String? : (Optional) Absolute path to the file containing Rhino's model parameters. If not set it will be set to the default location (.pv).
  • requireEndpoint bool? : (Optional) Boolean variable to indicate if Rhino should wait for a chunk of silence before finishing inference.

Returns

  • [Picovoice](#picovoice) an instance of the Picovoice platform.

Throws


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.

void process(List<int> frame)

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


Picovoice.delete()

Release the resources acquired by Picovoice (via Porcupine and Rhino engines).

void delete()

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.

class PicovoiceManager { }

PicovoiceManager.create()

Static creator for initializing Picovoice.

static create(
String accessKey,
String keywordPath,
WakeWordCallback wakeWordCallback,
String contextPath,
InferenceCallback inferenceCallback,
{double porcupineSensitivity = 0.5,
double rhinoSensitivity = 0.5,
String? porcupineModelPath,
String? rhinoModelPath,
bool requireEndpoint = true,
ProcessErrorCallback? processErrorCallback})

Parameters

  • accessKey String : AccessKey obtained from Picovoice Console.
  • keywordPath String : A List of absolute paths to keyword model file (.ppn).
  • wakeWordCallback WakeWordCallback : User-defined callback invoked upon detection of the wake phrase. The callback accepts no input arguments
  • contextPath String : Absolute path to the Rhino context file (.rhn).
  • inferenceCallback InferenceCallback : User-defined callback invoked upon completion of intent inference. The callback accepts a single input argument of type RhinoInference.
  • 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) Absolute path to the file containing Porcupine's model parameters. If not set it will be set to the default location (.pv).
  • rhinoModelPath String? : (Optional) Absolute path to the file containing Rhino's model parameters. If not set it will be set to the default location (.pv).
  • requireEndpoint bool? : (Optional) Boolean variable to indicate if Rhino should wait for a chunk of silence before finishing inference.
  • processErrorCallback ProcessErrorCallback : Reports errors that are encountered while the engine is processing audio.

Returns

Throws


PicovoiceManager.start()

Opens audio input stream and sends audio frames to Picovoice.

Future<void> start()

Throws


PicovoiceManager.stop()

Closes audio stream and stops Picovoice processing.

Future<void> stop()

ProcessErrorCallback

Type for the error callback that occurs while processing audio.

typedef ProcessErrorCallback = Function(PicovoiceException error);

Parameters


PicovoiceException

class PicovoiceException implements Exception { }

Exception thrown if an error occurs within Picovoice:

class PicovoiceMemoryException extends PicovoiceException { }
class PicovoiceIOException extends PicovoiceException { }
class PicovoiceInvalidArgumentException extends PicovoiceException { }
class PicovoiceStopIterationException extends PicovoiceException { }
class PicovoiceKeyException extends PicovoiceException { }
class PicovoiceInvalidStateException extends PicovoiceException { }
class PicovoiceRuntimeException extends PicovoiceException { }
class PicovoiceActivationException extends PicovoiceException { }
class PicovoiceActivationLimitException extends PicovoiceException { }
class PicovoiceActivationThrottledException extends PicovoiceException { }
class PicovoiceActivationRefusedException extends PicovoiceException { }


Issue with this doc? Please let us know.