Package ai.picovoice.picovoice
Class Picovoice
- java.lang.Object
-
- ai.picovoice.picovoice.Picovoice
-
public class Picovoice extends java.lang.ObjectJava binding for Picovoice end-to-end platform. Picovoice enables building voice experiences similar to Alexa but runs entirely on-device (offline).Picovoice detects utterances of a customizable wake word (phrase) within an incoming stream of audio in real-time. After detection of wake word, it begins to infer the user's intent from the follow-on spoken command. Upon detection of wake word and completion of voice command, it invokes user-provided callbacks to signal these events.
Picovoice processes incoming audio in consecutive frames. The number of samples per frame is $
getFrameLength(). The incoming audio needs to have a sample rate equal to $getSampleRate()and be 16-bit linearly-encoded. Picovoice operates on single-channel audio. It uses Porcupine wake word engine for wake word detection and Rhino Speech-to-Intent engine for intent inference.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPicovoice.BuilderBuilder for creating an instance of Picovoice with a mixture of default arguments
-
Constructor Summary
Constructors Constructor Description Picovoice(java.lang.String accessKey, java.lang.String porcupineLibraryPath, java.lang.String porcupineModelPath, java.lang.String keywordPath, float porcupineSensitivity, PicovoiceWakeWordCallback wakeWordCallback, java.lang.String rhinoLibraryPath, java.lang.String rhinoModelPath, java.lang.String contextPath, float rhinoSensitivity, boolean requireEndpoint, PicovoiceInferenceCallback inferenceCallback)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddelete()Releases resources acquired.java.lang.StringgetContextInformation()Getter for the Rhino contextintgetFrameLength()Getter for number of audio samples per frame..java.lang.StringgetPorcupineVersion()Getter for Porcupine version.java.lang.StringgetRhinoVersion()Getter for Rhino version.intgetSampleRate()Getter for audio sample rate accepted by Picovoice.java.lang.StringgetVersion()Getter for version.voidprocess(short[] pcm)Processes a frame of the incoming audio stream.
-
-
-
Constructor Detail
-
Picovoice
public Picovoice(java.lang.String accessKey, java.lang.String porcupineLibraryPath, java.lang.String porcupineModelPath, java.lang.String keywordPath, float porcupineSensitivity, PicovoiceWakeWordCallback wakeWordCallback, java.lang.String rhinoLibraryPath, java.lang.String rhinoModelPath, java.lang.String contextPath, float rhinoSensitivity, boolean requireEndpoint, PicovoiceInferenceCallback inferenceCallback) throws PicovoiceExceptionConstructor- Parameters:
accessKey- AccessKey obtained from Picovoice Console (https://console.picovoice.ai/)porcupineModelPath- Absolute path to the file containing Porcupine's model parameters.keywordPath- Absolute path to Porcupine's keyword model file.porcupineSensitivity- 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.wakeWordCallback- User-defined callback invoked upon detection of the wake phrase. $PicovoiceWakeWordCallbackdefines the interface of the callback.rhinoModelPath- Absolute path to the file containing Rhino's model parameters.contextPath- Absolute path to file containing context parameters. A context represents the set of expressions (spoken commands), intents, and intent arguments (slots) within a domain of interest.rhinoSensitivity- 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.requireEndpoint- If set to `False`, Rhino does not require an endpoint (chunk of silence) before finishing inference.inferenceCallback- User-defined callback invoked upon completion of intent inference. #PicovoiceInferenceCallbackdefines the interface of the callback.- Throws:
PicovoiceException- if there is an error while initializing.
-
-
Method Detail
-
delete
public void delete()
Releases resources acquired.
-
process
public void process(short[] pcm) throws PicovoiceExceptionProcesses 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- A frame of audio samples. The number of samples per frame can be attained by calling $getFrameLength(). The incoming audio needs to have a sample rate equal to $getSampleRate()and be 16-bit linearly-encoded. Picovoice operates on single-channel audio.- Throws:
PicovoiceException- if there is an error while processing the audio frame.
-
getVersion
public java.lang.String getVersion()
Getter for version.- Returns:
- Version.
-
getPorcupineVersion
public java.lang.String getPorcupineVersion()
Getter for Porcupine version.- Returns:
- Porcupine version.
-
getRhinoVersion
public java.lang.String getRhinoVersion()
Getter for Rhino version.- Returns:
- Rhino version.
-
getFrameLength
public int getFrameLength()
Getter for number of audio samples per frame..- Returns:
- Number of audio samples per frame.
-
getSampleRate
public int getSampleRate()
Getter for audio sample rate accepted by Picovoice.- Returns:
- Audio sample rate accepted by Picovoice.
-
getContextInformation
public java.lang.String getContextInformation()
Getter for the Rhino context- Returns:
- Rhino context
-
-