Picovoice Platform
Java API
API Reference for the Java Picovoice SDK (picovoice-java)
package: ai.picovoice.picovoice
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()
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 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).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()
Releases resources acquired by Picovoice
.
Picovoice.getFrameLength()
Getter for number of audio samples per frame.
Returns
int
: Number of audio samples per frame.
Picovoice.getSampleRate()
Getter for audio sample rate accepted by Picovoice.
Returns
int
: Audio sample rate accepted by Picovoice.
Picovoice.getVersion()
Getter for version.
Returns
String
: CurrentPicovoice
version.
Picovoice.getContextInformation()
Getter for context information.
Returns
String
: Returns the context information.
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
pcm
short[] : A frame of audio samples.
Throws
PicovoiceException
: If there is an error while processing the audio frame.
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 there is an error while resetting Picovoice state.
Picovoice.Builder
Builder for creating an instance of Picovoice
with a mixture of default arguments.
Picovoice.Builder.build()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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
Callback interface invoked when a keyword has been detected.
PicovoiceInferenceCallback
Callback interface invoked when a inference has been finalized.
Parameters
inference
RhinoInference : Object containing Rhino inference data.
PicovoiceException
Exception thrown if an error occurs within the Picovoice
engine.
Exceptions: