Picovoice WordmarkPicovoice Console
Introduction
Introduction
AndroidC.NETFlutterlink to GoiOSJavaNvidia JetsonLinuxmacOSNodejsPythonRaspberry PiReact NativeRustWebWindows
AndroidC.NETFlutterlink to GoiOSJavaNodejsPythonReact NativeRustWeb
SummaryPicovoice LeopardAmazon TranscribeAzure Speech-to-TextGoogle ASRGoogle ASR (Enhanced)IBM Watson Speech-to-Text
FAQ
Introduction
AndroidC.NETFlutterlink to GoiOSJavaNodejsPythonReact NativeRustWeb
AndroidC.NETFlutterlink to GoiOSJavaNodejsPythonReact NativeRustWeb
FAQ
Introduction
AndroidCiOSLinuxmacOSPythonWebWindows
AndroidCiOSPythonWeb
SummaryOctopus Speech-to-IndexGoogle Speech-to-TextMozilla DeepSpeech
FAQ
Introduction
AndroidAngularArduinoBeagleBoneCChrome.NETEdgeFirefoxFlutterlink to GoiOSJavaNvidia JetsonLinuxmacOSMicrocontrollerNodejsPythonRaspberry PiReactReact NativeRustSafariUnityVueWebWindows
AndroidAngularC.NETFlutterlink to GoiOSJavaMicrocontrollerNodejsPythonReactReact NativeRustUnityVueWeb
SummaryPorcupineSnowboyPocketSphinx
Wake Word TipsFAQ
Introduction
AndroidAngularBeagleBoneCChrome.NETEdgeFirefoxFlutterlink to GoiOSJavaNvidia JetsonlinuxmacOSNodejsPythonRaspberry PiReactReact NativeRustSafariUnityVueWebWindows
AndroidAngularC.NETFlutterlink to GoiOSJavaNodejsPythonReactReact NativeRustUnityVueWeb
SummaryPicovoice RhinoGoogle DialogflowAmazon LexIBM WatsonMicrosoft LUIS
Expression SyntaxFAQ
Introduction
AndroidBeagleboneCiOSNvidia JetsonLinuxmacOSPythonRaspberry PiRustWebWindows
AndroidCiOSPythonRustWeb
SummaryPicovoice CobraWebRTC VAD
FAQ
Introduction
AndroidAngularArduinoBeagleBoneC.NETFlutterlink to GoiOSJavaNvidia JetsonMicrocontrollerNodejsPythonRaspberry PiReactReact NativeRustUnityVueWeb
AndroidAngularCMicrocontroller.NETFlutterlink to GoiOSJavaNodejsPythonReactReact NativeRustUnityVueWeb
Picovoice SDK - FAQ
IntroductionSTM32F407G-DISC1 (Arm Cortex-M4)STM32F411E-DISCO (Arm Cortex-M4)STM32F769I-DISCO (Arm Cortex-M7)IMXRT1050-EVKB (Arm Cortex-M7)
FAQGlossary

Picovoice Platform — Java API


API Reference for the Java Picovoice SDK (picovoice-java)

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

public Picovoice(
String accessKey,
String porcupineLibraryPath,
String porcupineModelPath,
String keywordPath,
float porcupineSensitivity,
PicovoiceWakeWordCallback wakeWordCallback,
String rhinoLibraryPath,
String rhinoModelPath,
String contextPath,
float rhinoSensitivity,
float endpointDurationSec,
boolean requireEndpoint,
PicovoiceInferenceCallback inferenceCallback) throws PicovoiceException

Picovoice constructor. See also the Picovoice.Builder Class.

Parameters

  • accessKey String : AccessKey obtained from Picovoice Console.
  • porcupineModelPath String : Absolute path to the file containing Porcupine's model parameters.
  • keywordPath String : Absolute path to Porcupine's keyword model file.
  • porcupineSensitivity String : Wake word detection sensitivity. It should be a number within [0, 1].
  • wakeWordCallback String : User-defined callback invoked upon detection of the wake phrase. PicovoiceWakeWordCallback defines the interface of the callback.
  • rhinoModelPath String : Absolute path to the file containing Rhino's model parameters.
  • contextPath String : Absolute path to file containing Rhino context parameters.
  • sensitivity float : 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.
  • 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 boolean : If set to true, Rhino requires an endpoint (a chunk of silence) after the spoken command. If set to false, Rhino tries to detect silence, but if it cannot, it still will provide inference regardless. Set to false only if operating in an environment with overlapping speech (e.g. people talking in the background).
  • inferenceCallback String : User-defined callback invoked upon completion of intent inference. PicovoiceInferenceCallback defines the interface of the callback.

Returns

  • Picovoice: An instance of the Picovoice engine.

Throws

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

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

  • String: Current Picovoice version.

Picovoice.getContextInformation()

public String getContextInformation()

Getter for 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

  • PicovoiceException: If there is an error while processing the audio frame.

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 RhinoException

Creates an instance of the Picovoice engine.

Returns

  • Picovoice: An instance of the Picovoice engine.

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 to the builder.

Parameters

  • accessKey String : AccessKey obtained from Picovoice Console.

Returns

  • Picovoice.Builder: The instance of Picovoice.Builder object.

Picovoice.Builder.setPorcupineLibraryPath()

public Picovoice.Builder setPorcupineLibraryPath(String porcupineLibraryPath)

Sets the Porcupine library path to the builder.

Parameters

  • porcupineLibraryPath String : Absolute path to the file containing the Porcupine native library.

Returns

  • Picovoice.Builder: The instance of Picovoice.Builder object.

Picovoice.Builder.setPorcupineModelPath()

public Picovoice.Builder setPorcupineModelPath(String porcupineModelPath)

Sets the Porcupine model path to the builder.

Parameters

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

Returns

  • Picovoice.Builder: The instance of Picovoice.Builder object.

Picovoice.Builder.setKeywordPath()

public Picovoice.Builder setKeywordPath(String keywordPath)

Sets the Porcupine keyword path to the builder.

Parameters

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

Returns

  • Picovoice.Builder: The instance of Picovoice.Builder object.

Picovoice.Builder.setPorcupineSensitivity()

public Picovoice.Builder setPorcupineSensitivity(float porcupineSensitivity)

Sets Porcupine's keyword sensitivity to 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: The instance of Picovoice.Builder object.

Picovoice.Builder.setWakeWordCallback()

public Picovoice.Builder setWakeWordCallback(PicovoiceWakeWordCallback wakeWordCallback)

Sets the wake word callback object to the builder.

Parameters

  • wakeWordCallback PicovoiceWakeWordCallback : Wake word callback.

Returns

  • Picovoice.Builder: The instance of Picovoice.Builder object.

Picovoice.Builder.setRhinoLibraryPath()

public Picovoice.Builder setRhinoLibraryPath(String rhinoLibraryPath)

Sets the Rhino library path to the builder.

Parameters

  • rhinoLibraryPath String : Absolute path to the file containing the Rhino native library.

Returns

  • Picovoice.Builder: The instance of Picovoice.Builder object.

Picovoice.Builder.setRhinoModelPath()

public Picovoice.Builder setRhinoModelPath(String rhinoModelPath)

Sets the Rhino model path to the builder.

Parameters

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

Returns

  • Picovoice.Builder: The instance of Picovoice.Builder object.

Picovoice.Builder.setContextPath()

public Picovoice.Builder setContextPath(String contextPath)

Sets the Rhino context path to the builder.

Parameters

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

Returns

  • Picovoice.Builder: The instance of Picovoice.Builder object.

Picovoice.Builder.setRhinoSensitivity()

public Picovoice.Builder setRhinoSensitivity(float rhinoSensitivity)

Sets Rhino's sensitivity to 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 inferring intent.

Returns

  • Picovoice.Builder: The instance of Picovoice.Builder object.

Picovoice.Builder.setInferenceCallback()

public Picovoice.Builder setInferenceCallback(PicovoiceInferenceCallback inferenceCallback)

Sets the inference callback object to the builder.

Parameters

  • inferenceCallback PicovoiceInferenceCallback : Inference callback.

Returns

  • Picovoice.Builder: The instance of Picovoice.Builder object.

Picovoice.Builder.setRhinoEndpointDuration()

public Picovoice.Builder setRhinoEndpointDuration(float rhinoEndpointDuration)

Sets rhinoEndpointDuration to the builder. 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.

Parameters

  • rhinoEndpointDuration float: Endpoint duration in seconds.

Returns

  • Picovoice.Builder: The instance of Picovoice.Builder object.

Picovoice.Builder.setRequireEndpoint()

public Picovoice.Builder setRequireEndpoint(boolean requireEndpoint)

Sets requireEndpoint to the builder. If set to true, Rhino requires an endpoint (a chunk of silence) after the spoken command. If set to false, Rhino tries to detect silence, but if it cannot, it still will provide inference regardless. Set to false only if operating in an environment with overlapping speech (e.g. people talking in the background).

Parameters

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

Returns

  • Picovoice.Builder: The instance of Picovoice.Builder object.

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 a inference has been finalized.

Parameters

  • inference RhinoInference : Object containing Rhino inference data.

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 { }

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Picovoice Platform — Java API
  • Picovoice
  • Picovoice()
  • delete()
  • getFrameLength()
  • getSampleRate()
  • getVersion()
  • getContextInformation()
  • process()
  • Picovoice.Builder
  • build()
  • setAccessKey()
  • setPorcupineLibraryPath()
  • setPorcupineModelPath()
  • setKeywordPath()
  • setPorcupineSensitivity()
  • setWakeWordCallback()
  • setRhinoLibraryPath()
  • setRhinoModelPath()
  • setContextPath()
  • setRhinoSensitivity()
  • setInferenceCallback()
  • setRhinoEndpointDuration()
  • setRequireEndpoint()
  • PicovoiceWakeWordCallback
  • PicovoiceInferenceCallback
  • PicovoiceException
Platform
  • Leopard Speech-to-Text
  • Cheetah Streaming Speech-to-Text
  • Octopus Speech-to-Index
  • Porcupine Wake Word
  • Rhino Speech-to-Intent
  • Cobra Voice Activity Detection
Resources
  • Docs
  • Console
  • Blog
  • Demos
Sales
  • Pricing
  • Starter Tier
  • Enterprise
Company
  • Careers
Follow Picovoice
  • LinkedIn
  • GitHub
  • Twitter
  • Medium
  • YouTube
  • AngelList
Subscribe to our newsletter
Terms of Use
Privacy Policy
© 2019-2022 Picovoice Inc.