Package ai.picovoice.porcupine
Class Porcupine
java.lang.Object
ai.picovoice.porcupine.Porcupine
public class Porcupine
extends java.lang.Object
Android binding for Porcupine wake word engine. It detects utterances of given keywords within an
incoming stream of audio in real-time. It processes incoming audio in consecutive frames and for
each frame emits the detection result. 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. Porcupine operates on single-channel
audio.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPorcupine.BuilderBuilder for creating an instance of Porcupine with a mixture of default argumentsstatic classPorcupine.BuiltInKeyword -
Method Summary
Modifier and Type Method Description voiddelete()Releases resources acquired by Porcupine.intgetFrameLength()Getter for number of audio samples per frame..intgetSampleRate()Getter for audio sample rate accepted by Picovoice.java.lang.StringgetVersion()Getter for version.intprocess(short[] pcm)Processes a frame of the incoming audio stream and emits the detection result.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Method Details
-
delete
public void delete()Releases resources acquired by Porcupine. -
process
Processes a frame of the incoming audio stream and emits the detection result.- Parameters:
pcm- A frame of audio samples. The number of samples per frame can be attained by callinggetFrameLength(). The incoming audio needs to have a sample rate equal togetSampleRate()and be 16-bit linearly-encoded. Porcupine operates on single-channel audio.- Returns:
- Index of observed keyword at the end of the current frame. Indexing is 0-based and matches the ordering of keyword models provided to the constructor. If no keyword is detected then it returns -1.
- Throws:
PorcupineException- if there is an error while processing the audio frame.
-
getVersion
public java.lang.String getVersion()Getter for version.- Returns:
- 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.
-