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

Leopard Speech-to-Text
Java API

API Reference for the Java Leopard SDK (leopard-java)

package: ai.picovoice.leopard


Leopard

public class Leopard { }

Class for the Leopard Speech-to-Text engine.

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


Leopard.delete()

public void delete()

Releases resources acquired by Leopard.


Leopard.getSampleRate()

public int getSampleRate()

Getter for required audio sample rate for PCM data.

Returns

  • int: Required audio sample rate for PCM data.

Leopard.getVersion()

public String getVersion()

Getter for version.

Returns

  • String: Current Leopard version.

Leopard.process()

public LeopardTranscript process(short[] pcm) throws LeopardException

Processes given audio data and returns its transcription. The incoming audio needs to have a sample rate equal to .getSampleRate() and be 16-bit linearly-encoded. Furthermore, Leopard operates on single channel audio. If you wish to process data in a different sample rate or format consider using .processFile().

Parameters

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

Returns

  • LeopardTranscript: Inferred transcription and word metadata.

Throws

  • LeopardException: if there is an error while processing the audio frame.

Leopard.processFile()

public LeopardTranscript processFile(String path) throws LeopardException

Processes a given audio file and returns its transcription.

Parameters

  • path String : Absolute path to the audio file. The supported audio file formats are: 3gp (AMR), FLAC, MP3 , MP4/m4a (AAC), Ogg, WAV and WebM.

Returns

  • LeopardTranscript: Inferred transcription and word metadata.

Throws

  • LeopardException: if there is an error while processing the audio file.

Leopard.Builder

public static class Builder {
public Builder(String accessKey) { }
}

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

Parameters

  • accessKey String : AccessKey obtained from Picovoice Console.

Leopard.Builder.build()

public Leopard build() throws LeopardException

Creates an instance of Leopard Speech-to-Text engine.

Returns

  • Leopard: An instance of Leopard Speech-to-Text engine.

Throws

  • LeopardException: If an error occurs while creating an instance of Leopard Speech-to-Text engine.

Leopard.Builder.setAccessKey()

public Leopard.Builder setAccessKey(String accessKey)

Sets the AccessKey of the builder.

Parameters

  • accessKey String : AccessKey obtained from Picovoice Console.

Returns

  • Leopard.Builder: Modified Leopard.Builder object.

Leopard.Builder.setModelPath()

public Leopard.Builder setModelPath(String modelPath)

Sets the model path of the builder.

Parameters

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

Returns

  • Leopard.Builder: Modified Leopard.Builder object.

Leopard.Builder.setLibraryPath()

public Builder setLibraryPath(String libraryPath)

Sets the library path of the builder.

Parameters

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

Returns

  • Leopard.Builder: Modified Leopard.Builder object.

Leopard.Builder.setEnableAutomaticPunctuation()

public Leopard.Builder setEnableAutomaticPunctuation(boolean enableAutomaticPunctuation)

Setter for enabling automatic punctuation insertion.

Parameters

  • enableAutomaticPunctuation boolean : Set to true to enable automatic punctuation insertion.

Returns

  • Leopard.Builder: Modified Leopard.Builder object.

Leopard.Builder.setEnableDiarization()

public Leopard.Builder setEnableDiarization(boolean enableDiarization)

Setter for enabling speaker diarization.

Parameters

  • enableDiarization boolean : Set to true to enable speaker diarization, which allows Leopard to differentiate speakers as part of the transcription process. Word metadata will include a speakerTag to identify unique speakers.

Returns

  • Leopard.Builder: Modified Leopard.Builder object.

LeopardTranscript

public class LeopardTranscript {
public LeopardTranscript(String transcriptString, Word[] wordArray) { }
}

Class that contains transcription results returned from Leopard.process() and Leopard.processFile().

Parameters

  • transcriptString String : Inferred transcription.
  • wordArray LeopardTranscript.Word[] : Transcribed words and their associated metadata.

LeopardTranscript.getTranscriptString()

public String getTranscriptString()

Getter for the inferred transcription.

Returns

  • String: Inferred transcription.

LeopardTranscript.getWordArray()

public Word[] getWordArray()

Getter for transcribed words and their associated metadata.

Returns

  • LeopardTranscript.Word[]: Transcribed words and their associated metadata.

LeopardTranscript.Word

public static class Word {
public Word(String word, float confidence, float startSec, float endSec, int speakerTag) { }
}

Class for storing word metadata from a LeopardTranscript.

Parameters

  • word String : Transcribed word.
  • confidence float : Transcription confidence. It is a number within [0, 1].
  • startSec float : Start of word in seconds.
  • endSec float : End of word in seconds.
  • speakerTag int : The speaker tag is -1 if diarization is not enabled during initialization; otherwise, it's a non-negative integer identifying unique speakers, with 0 reserved for unknown speakers.

LeopardTranscript.Word.getWord()

public String getWord()

Getter for the transcribed word.

Returns

  • String: Transcribed word.

LeopardTranscript.Word.getConfidence()

public float getConfidence()

Getter for the transcription confidence.

Returns

  • float: Transcription confidence. It is a number within [0, 1].

LeopardTranscript.Word.getStartSec()

public float getStartSec()

Getter for the start of word in seconds.

Returns

  • float: Start of word in seconds.

LeopardTranscript.Word.getEndSec()

public float getEndSec()

Getter for the end of word in seconds.

Returns

  • float: End of word in seconds.

LeopardTranscript.Word.getSpeakerTag()

public int getSpeakerTag()

Getter for the speaker tag.

Returns

  • int: Speaker tag associated with speaker.

LeopardException

public class LeopardException extends Exception { }

Exception thrown if an error occurs within Leopard Speech-to-Text engine.

Exceptions:

public class LeopardActivationException extends LeopardException { }
public class LeopardActivationLimitException extends LeopardException { }
public class LeopardActivationRefusedException extends LeopardException { }
public class LeopardActivationThrottledException extends LeopardException { }
public class LeopardIOException extends LeopardException { }
public class LeopardInvalidArgumentException extends LeopardException { }
public class LeopardInvalidStateException extends LeopardException { }
public class LeopardKeyException extends LeopardException { }
public class LeopardMemoryException extends LeopardException { }
public class LeopardRuntimeException extends LeopardException { }
public class LeopardStopIterationException extends LeopardException { }

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Leopard Speech-to-Text Java API
  • Leopard
  • delete()
  • getSampleRate()
  • getVersion()
  • process()
  • processFile()
  • Leopard.Builder
  • build()
  • setAccessKey()
  • setModelPath()
  • setLibraryPath()
  • setEnableAutomaticPunctuation()
  • setEnableDiarization()
  • LeopardTranscript
  • getTranscriptString()
  • getWordArray()
  • LeopardTranscript.Word
  • getWord()
  • getConfidence()
  • getStartSec()
  • getEndSec()
  • getSpeakerTag()
  • LeopardException
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.