androidPicovoice Platform — Android API

API Reference for the Android Picovoice SDK (picovoice-android)

package: ai.picovoice.picovoice


Picovoice

public class Picovoice { }

Class for the Picovoice engine.

Picovoice can be initialized using the Picovoice.Builder Class. Resources should be cleaned when you are done using the delete() function.


Picovoice.delete()

public void delete()

Releases resources acquired by Picovoice.


Picovoice.getFrameLength()

public int getFrameLength()

Getter for number of audio samples per frame.

Returns

  • int: Number of audio samples per frame.

Picovoice.getSampleRate()

public int getSampleRate()

Getter for audio sample rate accepted by Picovoice.

Returns

  • int: Audio sample rate accepted by Picovoice.

Picovoice.getVersion()

public String getVersion()

Getter for version.

Returns


Picovoice.getPorcupineVersion()

public String getPorcupineVersion()

Getter for the version of Porcupine.

Returns


Picovoice.getRhinoVersion()

public String getRhinoVersion()

Getter for the version of Rhino.

Returns

  • String: Current Rhino version.

Picovoice.getContextInformation()

public String getContextInformation()

Getter for Rhino context information.

Returns

  • String: Returns the context information.

Picovoice.process()

public void process(short[] pcm) throws PicovoiceException

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

  • pcm short[] : A frame of audio samples.

Throws


Picovoice.Builder

public static class Builder { }

Builder for creating an instance of Picovoice with a mixture of default arguments.


Picovoice.Builder.build()

public Picovoice build() throws PicovoiceException

Creates an instance of the Picovoice platform.

Returns

  • Picovoice: An instance of the Picovoice platform.

Throws

  • PicovoiceException: If an error occurs while creating an instance of the Picovoice engine.

Picovoice.Builder.setAccessKey()

public Picovoice.Builder setAccessKey(String accessKey)

Sets the AccessKey of the builder.

Parameters

Returns


Picovoice.Builder.setPorcupineModelPath()

public Picovoice.Builder setPorcupineModelPath(String porcupineModelPath)

Sets the Porcupine model path of the builder.

Parameters

  • porcupineModelPath String : Absolute path to the file containing the Porcupine model parameters (.pv).

Returns


Picovoice.Builder.setKeywordPath()

public Picovoice.Builder setKeywordPath(String keywordPath)

Sets the Porcupine keyword path of the builder.

Parameters

  • keywordPath String : Absolute path to the file containing the Porcupine keyword model (.ppn).

Returns


Picovoice.Builder.setPorcupineSensitivity()

public Picovoice.Builder setPorcupineSensitivity(float porcupineSensitivity)

Sets Porcupine's keyword sensitivity of the builder. Value should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate.

Parameters

  • porcupineSensitivity float : Sensitivity for detecting keyword.

Returns


Picovoice.Builder.setWakeWordCallback()

public Picovoice.Builder setWakeWordCallback(PicovoiceWakeWordCallback wakeWordCallback)

Sets the wake word callback object of the builder.

Parameters

Returns


Picovoice.Builder.setRhinoModelPath()

public Picovoice.Builder setRhinoModelPath(String rhinoModelPath)

Sets the Rhino model path of the builder.

Parameters

  • rhinoModelPath String : Absolute path to the file containing the Rhino model parameters (.pv).

Returns


Picovoice.Builder.setContextPath()

public Picovoice.Builder setContextPath(String contextPath)

Sets the Rhino context path of the builder.

Parameters

  • contextPath String : Absolute path to the file containing the Rhino context model (.rhn).

Returns


Picovoice.Builder.setRhinoSensitivity()

public Picovoice.Builder setRhinoSensitivity(float rhinoSensitivity)

Sets Rhino's sensitivity of the builder. Value should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate.

Parameters

  • rhinoSensitivity float : Sensitivity for intent inference.

Returns


Picovoice.Builder.setInferenceCallback()

public Picovoice.Builder setInferenceCallback(PicovoiceInferenceCallback inferenceCallback)

Sets the inference callback object of the builder.

Parameters

Returns


Picovoice.Builder.setRequireEndpoint()

public Picovoice.Builder setRequireEndpoint(boolean requireEndpoint)

Sets requireEndpoint of the builder. If set to false, Rhino does not require an endpoint (chunk of silence) before finishing inference.

Parameters

  • requireEndpoint boolean: Indicates whether an endpoint is required for Rhino to finish inference.

Returns


PicovoiceException

public class PicovoiceException extends Exception { }

Exception thrown if an error occurs within the Picovoice engine.

Exceptions:

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

PicovoiceManager

public class PicovoiceManager { }

High-level Android binding for Picovoice platform. It handles recording audio from microphone, processes it in real-time, and notifies the client upon detection of the wake word or completion of in voice command inference.


PicovoiceManager.delete()

public void delete()

Releases resources acquired by PicovoiceManager.


PicovoiceManager.getVersion()

public String getVersion()

Getter for version.

Returns


PicovoiceManager.getPorcupineVersion()

public String getPorcupineVersion()

Getter for the version of Porcupine.

Returns


PicovoiceManager.getRhinoVersion()

public String getRhinoVersion()

Getter for the version of Rhino.

Returns

  • String: Current Rhino version.

PicovoiceManager.getContextInformation()

public String getContextInformation()

Getter for Rhino context information.

Returns

  • String: Returns the context information.

PicovoiceManager.start()

public void start() throws PicovoiceException

Starts recording audio from the microphone and processes using Picovoice.

Throws


PicovoiceManager.stop()

public void stop() throws PicovoiceException

Stops recording audio from the microphone.

Throws


PicovoiceManager.getContextInformation()

public String getContextInformation()

Getter for context information.

Returns

  • String: Returns the context information.

PicovoiceManager.Builder

public static class Builder { }

Builder for creating an instance of PicovoiceManager with a mixture of default arguments.


PicovoiceManager.Builder.build()

public PicovoiceManager build(Context context)

Creates an instance of PicovoiceManager.

Parameters

  • context Context : The Android app context.

Returns


PicovoiceManager.Builder.setAccessKey()

public PicovoiceManager.Builder setAccessKey(String accessKey)

Sets the AccessKey of the builder.

Parameters

Returns


PicovoiceManager.Builder.setPorcupineModelPath()

public PicovoiceManager.Builder setPorcupineModelPath(String porcupineModelPath)

Sets the Porcupine model path of the builder.

Parameters

  • porcupineModelPath String : Absolute path to the file containing the Porcupine model parameters (.pv).

Returns


PicovoiceManager.Builder.setKeywordPath()

public PicovoiceManager.Builder setKeywordPath(String keywordPath)

Sets the Porcupine keyword path of the builder.

Parameters

  • keywordPath String : Absolute path to the file containing the Porcupine keyword model (.ppn).

Returns


PicovoiceManager.Builder.setPorcupineSensitivity()

public PicovoiceManager.Builder setPorcupineSensitivity(float porcupineSensitivity)

Sets Porcupine's keyword sensitivity of the builder. Value should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate.

Parameters

  • porcupineSensitivity float : Sensitivity for detecting keyword.

Returns


PicovoiceManager.Builder.setWakeWordCallback()

public PicovoiceManager.Builder setWakeWordCallback(PicovoiceWakeWordCallback wakeWordCallback)

Sets the wake word callback object of the builder.

Parameters

Returns


PicovoiceManager.Builder.setRhinoModelPath()

public PicovoiceManager.Builder setRhinoModelPath(String rhinoModelPath)

Sets the Rhino model path of the builder.

Parameters

  • rhinoModelPath String : Absolute path to the file containing the Rhino model parameters (.pv).

Returns


PicovoiceManager.Builder.setContextPath()

public PicovoiceManager.Builder setContextPath(String contextPath)

Sets the Rhino context path of the builder.

Parameters

  • contextPath String : Absolute path to the file containing the Rhino context model (.rhn).

Returns


PicovoiceManager.Builder.setRhinoSensitivity()

public PicovoiceManager.Builder setRhinoSensitivity(float rhinoSensitivity)

Sets Rhino's sensitivity of the builder. Value should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate.

Parameters

  • rhinoSensitivity float : Sensitivity for intent inference.

Returns


PicovoiceManager.Builder.setInferenceCallback()

public PicovoiceManager.Builder setInferenceCallback(PicovoiceInferenceCallback inferenceCallback)

Sets the inference callback object of the builder.

Parameters

Returns


PicovoiceManager.Builder.setRequireEndpoint()

public Picovoice.Builder setRequireEndpoint(boolean requireEndpoint)

Sets requireEndpoint of the builder. If set to false, Rhino does not require an endpoint (chunk of silence) before finishing inference.

Parameters

  • requireEndpoint boolean: Indicates whether an endpoint is required for Rhino to finish inference.

Returns


PicovoiceManager.Builder.setProcessErrorCallback()

public PicovoiceManager.Builder setProcessErrorCallback(PicovoiceManagerErrorCallback errorCallback)

Sets errorCallback of the builder.

Parameters

Returns


PicovoiceWakeWordCallback

public interface PicovoiceWakeWordCallback {
void invoke();
}

Callback interface invoked when a keyword has been detected.


PicovoiceInferenceCallback

public interface PicovoiceInferenceCallback {
void invoke(RhinoInference inference);
}

Callback interface invoked when inference has been finalized.

Parameters


PicovoiceManagerErrorCallback

public interface PicovoiceManagerErrorCallback {
void invoke(PicovoiceException error);
}

Callback interface invoked when an error occurs while processing audio.


Issue with this doc? Please let us know.