Picovoice WordmarkPicovoice Console
Introduction
Introduction
AndroidC.NETFlutterlink to GoiOSJavaNvidia JetsonLinuxmacOSNodejsPythonRaspberry PiReact NativeRustWebWindows
AndroidC.NETFlutterlink to GoiOSJavaNodejsPythonReact NativeRustWeb
SummaryPicovoice LeopardAmazon TranscribeAzure Speech-to-TextGoogle ASRGoogle ASR (Enhanced)IBM Watson Speech-to-Text
FAQ
Introduction
AndroidC.NETFlutterlink to GoiOSJavaNodejsPythonReact NativeRustWeb
AndroidC.NETFlutterlink to GoiOSJavaNodejsPythonReact NativeRustWeb
FAQ
Introduction
AndroidCiOSLinuxmacOSPythonWebWindows
AndroidCiOSPythonWeb
SummaryOctopus Speech-to-IndexGoogle Speech-to-TextMozilla DeepSpeech
FAQ
Introduction
AndroidAngularArduinoBeagleBoneCChrome.NETEdgeFirefoxFlutterlink to GoiOSJavaNvidia JetsonLinuxmacOSMicrocontrollerNodejsPythonRaspberry PiReactReact NativeRustSafariUnityVueWebWindows
AndroidAngularC.NETFlutterlink to GoiOSJavaMicrocontrollerNodejsPythonReactReact NativeRustUnityVueWeb
SummaryPorcupineSnowboyPocketSphinx
Wake Word TipsFAQ
Introduction
AndroidAngularBeagleBoneCChrome.NETEdgeFirefoxFlutterlink to GoiOSJavaNvidia JetsonlinuxmacOSNodejsPythonRaspberry PiReactReact NativeRustSafariUnityVueWebWindows
AndroidAngularC.NETFlutterlink to GoiOSJavaNodejsPythonReactReact NativeRustUnityVueWeb
SummaryPicovoice RhinoGoogle DialogflowAmazon LexIBM WatsonMicrosoft LUIS
Expression SyntaxFAQ
Introduction
AndroidBeagleboneCiOSNvidia JetsonLinuxmacOSPythonRaspberry PiRustWebWindows
AndroidCiOSPythonRustWeb
SummaryPicovoice CobraWebRTC VAD
FAQ
Introduction
AndroidAngularArduinoBeagleBoneC.NETFlutterlink to GoiOSJavaNvidia JetsonMicrocontrollerNodejsPythonRaspberry PiReactReact NativeRustUnityVueWeb
AndroidAngularCMicrocontroller.NETFlutterlink to GoiOSJavaNodejsPythonReactReact NativeRustUnityVueWeb
Picovoice SDK - FAQ
IntroductionSTM32F407G-DISC1 (Arm Cortex-M4)STM32F411E-DISCO (Arm Cortex-M4)STM32F769I-DISCO (Arm Cortex-M7)IMXRT1050-EVKB (Arm Cortex-M7)
FAQGlossary

Leopard Speech-to-Text
Android API


API Reference for the Android Leopard SDK (leopard-android)

package: ai.picovoice.leopard


Leopard

public class Leopard { }

Class for the Leopard Speech-to-Text engine.

Leopard must be initialized using the 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 on device. 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 { }

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


Leopard.Builder.build()

public Leopard build(Context context) throws LeopardException

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

Parameters

  • context Context : The Android app context.

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 : Path to the file containing model parameters (.pv). Can be either a path that is relative to the project's assets folder or an absolute path to the file on device.

Returns

  • Leopard.Builder: Modified Leopard.Builder object.

Leopard.Builder.setEnableAutomaticPunctuation()

public Leopard.Builder setEnableAutomaticPunctuation(boolean setEnableAutomaticPunctuation)

Setter for enabling automatic punctuation insertion.

Parameters

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

Returns

  • Leopard.Builder: Modified Leopard.Builder object.

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 { }

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) { }
}

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.

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.

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Leopard Speech-to-Text Android API
  • Leopard
  • delete()
  • getSampleRate()
  • getVersion()
  • process()
  • processFile()
  • Leopard.Builder
  • build()
  • setAccessKey()
  • setModelPath()
  • setEnableAutomaticPunctuation()
  • LeopardException
  • LeopardTranscript
  • getTranscriptString()
  • getWordArray()
  • LeopardTranscript.Word
  • getWord()
  • getConfidence()
  • getStartSec()
  • getEndSec()
Platform
  • Leopard Speech-to-Text
  • Cheetah Streaming Speech-to-Text
  • Octopus Speech-to-Index
  • Porcupine Wake Word
  • Rhino Speech-to-Intent
  • Cobra Voice Activity Detection
Resources
  • Docs
  • Console
  • Blog
  • Demos
Sales
  • Pricing
  • Starter Tier
  • Enterprise
Company
  • Careers
Follow Picovoice
  • LinkedIn
  • GitHub
  • Twitter
  • Medium
  • YouTube
  • AngelList
Subscribe to our newsletter
Terms of Use
Privacy Policy
© 2019-2022 Picovoice Inc.