unityPicovoice Platform - Unity API

API Reference for the Picovoice Unity SDK.


package: Pv.Unity


Picovoice

public class Picovoice : IDisposable

Class for the Picovoice Platform.


Picovoice.ContextInfo

public string ContextInfo { get; }

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

public int FrameLength { get; }

Gets the required number of audio samples-per-frame.

Returns

  • int : Required frame length.

Picovoice.SampleRate

public int SampleRate { get; }

Get the audio sample rate required by Picovoice.

Returns

  • int : Required sample rate in Hz.

Picovoice.PorcupineVersion

public string PorcupineVersion { get; }

Gets the version number of the Porcupine library.

Returns

  • string : Version of Porcupine.

Picovoice.RhinoVersion

public string RhinoVersion { get; }

Gets the version number of the Rhino library.

Returns

  • string : Version of Rhino.

Picovoice.Version

public string Version { get; }

Gets the version number of the Picovoice Platform.

Returns

  • string : Version of Picovoice.

Picovoice.Create()

public static Picovoice Create(
string accessKey,
string keywordPath,
Action wakeWordCallback,
string contextPath,
Action<Inference> inferenceCallback,
string porcupineModelPath = null,
float porcupineSensitivity = 0.5f,
string rhinoModelPath = null,
float rhinoSensitivity = 0.5f,
bool requireEndpoint = true)

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].
  • requireEndpoint requireEndpoint : If set to false, Rhino does not require an endpoint (chunk of silence) before finishing inference.

Returns

  • Picovoice : An instance of the Picovoice Platform.

Throws


Picovoice.Dispose()

public void Dispose()

Explicitly releases resources acquired by Picovoice.


Picovoice.Process()

public void Process(short[] pcm)

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

public class PicovoiceException : Exception

Exception thrown if an error is encountered by the Picovoice Platform.

Exceptions:

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

PicovoiceManager

public class 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

public bool IsAudioDeviceAvailable { get; }

Checks whether there are any audio capture devices available.


PicovoiceManager.IsRecording

public bool IsRecording { get; }

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()

public static PicovoiceManager Create(
string accessKey,
string keywordPath,
Action wakeWordCallback,
string contextPath,
Action<Inference> inferenceCallback,
string porcupineModelPath = null,
float porcupineSensitivity = 0.5f,
string rhinoModelPath = null,
float rhinoSensitivity = 0.5f,
bool requireEndpoint = false,
Action<PicovoiceException> processErrorCallback = null)

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].
  • requireEndpoint requireEndpoint : If set to false, Rhino does not require an endpoint (chunk of silence) before finishing inference.
  • processErrorCallback Action<PicovoiceException> : A callback that reports errors that are encountered while the engine is processing audio.

Returns

Throws


PicovoiceManager.Delete()

public void Delete()

Free resources that were allocated to PicovoiceManager.


PicovoiceManager.Start()

public void Start()

Starts capturing audio and passing it to the Picovoice Platform.

Throws


PicovoiceManager.Stop()

public void Stop()

Stops audio capture and processing.

Throws


Issue with this doc? Please let us know.