Picovoice Wordmark
Start Building
Introduction
Introduction
AndroidC.NETiOSLinuxmacOSNode.jsPythonRaspberry PiWebWindows
AndroidC.NETiOSNode.jsPythonWeb
SummaryPicovoice picoLLMGPTQ
Introduction
AndroidC.NETFlutteriOSJavaLinuxmacOSNode.jsPythonRaspberry PiReactReact NativeRustWebWindows
AndroidC.NETFlutteriOSJavaNode.jsPythonReactReact NativeRustWeb
SummaryPicovoice LeopardAmazon TranscribeAzure Speech-to-TextGoogle ASRGoogle ASR (Enhanced)IBM Watson Speech-to-TextWhisper Speech-to-Text
FAQ
Introduction
AndroidC.NETFlutteriOSJavaLinuxmacOSNode.jsPythonRaspberry PiReactReact NativeRustWebWindows
AndroidC.NETFlutteriOSJavaNode.jsPythonReactReact NativeRustWeb
SummaryPicovoice Cheetah
FAQ
Introduction
AndroidC.NETiOSLinuxmacOSNode.jsPythonRaspberry PiWebWindows
AndroidC.NETiOSNode.jsPythonWeb
SummaryAmazon PollyAzure TTSElevenLabsOpenAI TTSPicovoice Orca
Introduction
AndroidCiOSLinuxmacOSPythonRaspberry PiWebWindows
AndroidCiOSPythonWeb
SummaryPicovoice KoalaMozilla RNNoise
Introduction
AndroidCiOSLinuxmacOSNode.jsPythonRaspberry PiWebWindows
AndroidCNode.jsPythoniOSWeb
SummaryPicovoice EaglepyannoteSpeechBrainWeSpeaker
Introduction
AndroidCiOSLinuxmacOSPythonRaspberry PiWebWindows
AndroidCiOSPythonWeb
SummaryPicovoice FalconAmazon TranscribeAzure Speech-to-TextGoogle Speech-to-Textpyannote
Introduction
AndroidArduinoCChrome.NETEdgeFirefoxFlutteriOSJavaLinuxmacOSMicrocontrollerNode.jsPythonRaspberry PiReactReact NativeRustSafariUnityWebWindows
AndroidC.NETFlutteriOSJavaMicrocontrollerNode.jsPythonReactReact NativeRustUnityWeb
SummaryPorcupineSnowboyPocketSphinx
Wake Word TipsFAQ
Introduction
AndroidCChrome.NETEdgeFirefoxFlutteriOSJavaLinuxmacOSNode.jsPythonRaspberry PiReactReact NativeRustSafariUnityWebWindows
AndroidC.NETFlutteriOSJavaNode.jsPythonReactReact NativeRustUnityWeb
SummaryPicovoice RhinoGoogle DialogflowAmazon LexIBM WatsonMicrosoft LUIS
Expression SyntaxFAQ
Introduction
AndroidC.NETiOSLinuxmacOSNode.jsPythonRaspberry PiRustWebWindows
AndroidC.NETiOSNode.jsPythonRustWeb
SummaryPicovoice CobraWebRTC VAD
FAQ
Introduction
AndroidC.NETFlutteriOSNode.jsPythonReact NativeRustUnityWeb
AndroidC.NETFlutteriOSNode.jsPythonReact NativeRustUnityWeb
Introduction
C.NETNode.jsPython
C.NETNode.jsPython
FAQGlossary

Porcupine Wake Word
Java API

API Reference for the Java Porcupine SDK (porcupine-java)

package: ai.picovoice.porcupine


Porcupine

public class Porcupine { }

Class for the Porcupine wake word engine.

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


Porcupine.Porcupine()

public Porcupine(
String accessKey,
String libraryPath,
String modelPath,
String[] keywordPaths,
float[] sensitivities) throws PorcupineException

Porcupine constructor. See also the Porcupine.Builder Class.

Parameters

  • accessKey String : AccessKey obtained from Picovoice Console.
  • libraryPath String : Absolute path to the native Porcupine library.
  • modelPath String : Absolute path to the file containing model parameters.
  • keywordPaths String[] : Absolute paths to keyword model files.
  • sensitivities float[] : Sensitivities for detecting keywords. Each value should be a number within [0, 1].

Returns

  • Porcupine: An instance of Porcupine wake word engine.

Throws

  • PorcupineException: If an error occurs while creating an instance of Porcupine wake word engine.

Porcupine.delete()

public void delete()

Releases resources acquired by Porcupine.


Porcupine.getFrameLength()

public int getFrameLength()

Getter for number of audio samples per frame.

Returns

  • int: Number of audio samples per frame.

Porcupine.getSampleRate()

public int getSampleRate()

Getter for audio sample rate accepted by Picovoice.

Returns

  • int: Audio sample rate accepted by Picovoice.

Porcupine.getVersion()

public String getVersion()

Getter for version.

Returns

  • String: Current Porcupine version.

Porcupine.process()

public int process(short[] pcm) throws PorcupineException

Processes a frame of the incoming audio stream and 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.

Parameters

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

Returns

  • int: 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.

Porcupine.BuiltInKeyword

public enum BuiltInKeyword { }

Enum of available built-in keywords for Porcupine wake word engine.

Values:

  • ALEXA
  • AMERICANO
  • BLUEBERRY
  • BUMBLEBEE
  • COMPUTER
  • GRAPEFRUIT
  • GRASSHOPPER
  • HEY_GOOGLE
  • HEY_SIRI
  • JARVIS
  • OK_GOOGLE
  • PICOVOICE
  • PORCUPINE
  • TERMINATOR

Porcupine.Builder

public static class Builder { }

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


Porcupine.Builder.build()

public Porcupine build() throws PorcupineException

Creates an instance of Porcupine wake word engine.

Returns

  • Porcupine: An instance of Porcupine wake word engine.

Throws

  • PorcupineException: If an error occurs while creating an instance of Porcupine wake word engine.

Porcupine.Builder.setAccessKey()

public Porcupine.Builder setAccessKey(String accessKey)

Sets the AccessKey to the builder.

Parameters

  • accessKey String : AccessKey obtained from Picovoice Console.

Returns

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

Porcupine.Builder.setBuiltInKeyword()

public Porcupine.Builder setBuiltInKeyword(BuiltInKeyword keyword)

Sets one keyword to the builder. This will replace the keywords set with setBuiltInKeywords().

build() will throw a PorcupineException if set together with setKeywordPath() or setKeywordPaths().

Parameters

  • keyword BuiltinKeyword : A keyword used for detection.

Returns

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

Porcupine.Builder.setBuiltInKeywords()

public Porcupine.Builder setBuiltInKeywords(BuiltInKeyword[] keywords)

Sets keywords to the builder. This will replace the keyword set with setBuiltInKeyword().

build() will throw a PorcupineException if set together with setKeywordPath() or setKeywordPaths().

Parameters

  • keywords BuiltInKeyword[] : List of keywords for detection.

Returns

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

Porcupine.Builder.setKeywordPath()

public Porcupine.Builder setKeywordPath(String keywordPath)

Sets one keywordPath to the builder. This will replace the keywordPaths set with setKeywordPaths().

build() will throw a PorcupineException if set together with setBuiltInKeyword() or setBuiltInKeywords().

Parameters

  • keywordPath String : Absolute path to one keyword file.

Returns

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

Porcupine.Builder.setKeywordPaths()

public Porcupine.Builder setKeywordPaths(String[] keywordPaths)

Sets keywordPaths to the builder. This will replace the keywordPath set with setKeywordPath().

build() will throw a PorcupineException if set together with setBuiltInKeyword() or setBuiltInKeywords().

Parameters

  • keywordPaths String[] : Absolute paths to keyword model files.

Returns

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

Porcupine.Builder.setLibraryPath()

public Porcupine.Builder setLibraryPath(String libraryPath)

Sets the native library path to the builder. If not set it will be set to the default location.

Parameters

  • libraryPath String : Absolute path to the native Porcupine library.

Returns

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

Porcupine.Builder.setModelPath()

public Porcupine.Builder setModelPath(String modelPath)

Sets the model path to the builder. If not set it will be set to the default location.

Parameters

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

Returns

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

Porcupine.Builder.setSensitivity()

public Porcupine.Builder setSensitivity(float sensitivity)

Sets sensitivity to the build. Value should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate. This will replace the sensitivities set with setSensitivities().

This should be used if setBuiltInKeyword() or setKeywordPath() was used.

Parameters

  • sensitivity float: Sensitivity for detecting keyword.

Returns

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

Porcupine.Builder.setSensitivities()

public Porcupine.Builder setSensitivities(float[] sensitivities)

Sets sensitivities to the build. Each value should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate.

This should be the same size as the number of keywords or keywordPaths set by setBuiltInKeywords() setKeywordPaths(). If not set, each will be set to 0.5. This will replace the sensitivity set with setSensitivity().

Parameters

  • sensitivities float[] : Sensitivities for detecting keywords.

Returns

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

PorcupineException

public class PorcupineException extends Exception { }

Exception thrown if an error occurs within Porcupine wake word engine.

Exceptions:

public class PorcupineActivationException extends PorcupineException { }
public class PorcupineActivationLimitException extends PorcupineException { }
public class PorcupineActivationRefusedException extends PorcupineException { }
public class PorcupineActivationThrottledException extends PorcupineException { }
public class PorcupineIOException extends PorcupineException { }
public class PorcupineInvalidArgumentException extends PorcupineException { }
public class PorcupineInvalidStateException extends PorcupineException { }
public class PorcupineKeyException extends PorcupineException { }
public class PorcupineMemoryException extends PorcupineException { }
public class PorcupineRuntimeException extends PorcupineException { }
public class PorcupineStopIterationException extends PorcupineException { }

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Porcupine Wake Word Java API
  • Porcupine
  • Porcupine()
  • delete()
  • getFrameLength()
  • getSampleRate()
  • getVersion()
  • process()
  • BuiltInKeyword
  • Porcupine.Builder
  • build()
  • setAccessKey()
  • setBuiltInKeyword()
  • setBuiltInKeywords()
  • setKeywordPath()
  • setKeywordPaths()
  • setLibraryPath()
  • setModelPath()
  • setSensitivity()
  • setSensitivities()
  • PorcupineException
Voice AI
  • Leopard Speech-to-Text
  • Cheetah Streaming Speech-to-Text
  • Orca Text-to-Speech
  • Koala Noise Suppression
  • Eagle Speaker Recognition
  • Falcon Speaker Diarization
  • Porcupine Wake Word
  • Rhino Speech-to-Intent
  • Cobra Voice Activity Detection
Local LLM
  • picoLLM Inference
  • picoLLM Compression
  • picoLLM GYM
Resources
  • Docs
  • Console
  • Blog
  • Use Cases
  • Playground
Sales & Services
  • Consulting
  • Foundation Plan
  • Enterprise Plan
  • Enterprise Support
Company
  • About us
  • Careers
Follow Picovoice
  • LinkedIn
  • GitHub
  • X
  • YouTube
  • AngelList
Subscribe to our newsletter
Terms of Use
Privacy Policy
© 2019-2025 Picovoice Inc.