pythonLeopard - Python API

API Reference for the Python Leopard SDK (PyPI).


pvleopard.create()

def create(
access_key: str,
library_path: Optional[str] = None,
model_path: Optional[str] = None) -> Leopard

Factory method for Leopard Speech-to-Text engine.

Parameters

  • access_key str : AccessKey obtained from Picovoice Console.
  • library_path Optional[str] : Absolute path to Leopard's dynamic library.
  • model_path Optional[str] : Absolute path to the file containing model parameters.

Returns

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

Throws


pvleopard.Leopard

class Leopard(object)

Class for the Leopard Speech-to-Text engine. Leopard can be initialized either using the module level create() function or directly using the class __init__() method. Resources should be cleaned when you are done using the delete() method.


pvleopard.Leopard.version

self.version: str

The version string of the Leopard library.


pvleopard.Leopard.sample_rate

self.sample_rate: int

The audio sample rate the Leopard accepts.


pvleopard.Leopard.__init__()

def __init__(
self,
access_key: str,
library_path: str,
model_path: str) -> Leopard

__init__ method for Leopard Speech-to-Text engine.

Parameters

  • access_key str : AccessKey obtained from Picovoice Console.
  • library_path str : Absolute path to Leopard's dynamic library.
  • model_path str : Absolute path to the file containing model parameters.

Returns

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

Throws


pvleopard.Leopard.delete()

def delete(self)

Releases resources acquired by Leopard.


pvleopard.Leopard.process()

def process(self, pcm: List[int]) -> str

Processes a given audio data and returns its transcription. The audio needs to have a sample rate equal to .sample_rate and be 16-bit linearly-encoded. This function operates on single-channel audio. If you wish to process data in a different sample rate or format consider using .process_file().

Parameters

  • pcm List[int] : Audio data.

Returns

  • str : Inferred transcription.

Throws


pvleopard.Leopard.process_file()

def process_file(self, audio_path: str) -> str

Processes a given audio file and returns its transcription. The file needs to have a sample rate equal to or greater than .sample_rate. The supported formats are: FLAC, MP3, Ogg, Opus, Vorbis, WAV, and WebM.

Parameters

  • audio_path str : Absolute path to the audio file.

Returns

  • str : Inferred transcription.

Throws


pvleopard.LeopardError

class LeopardError(Exception)

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

Exceptions

class LeopardActivationError(LeopardError)
class LeopardActivationLimitError(LeopardError)
class LeopardActivationRefusedError(LeopardError)
class LeopardActivationThrottledError(LeopardError)
class LeopardIOError(LeopardError)
class LeopardInvalidArgumentError(LeopardError)
class LeopardInvalidStateError(LeopardError)
class LeopardKeyError(LeopardError)
class LeopardMemoryError(LeopardError)
class LeopardRuntimeError(LeopardError)
class LeopardStopIterationError(LeopardError)

Issue with this doc? Please let us know.