react-nativeLeopard Platform — React Native API

API Reference for the React Native Leopard SDK (npm)


Leopard

class Leopard { }

Class for the Leopard Speech-to-Text engine.


Leopard.create()

public static async create(
accessKey: string,
modelPath: string
): Promise<Leopard>

Leopard constructor.

Parameters

  • accessKey string : AccessKey obtained from Picovoice Console.
  • modelPath string : Path to the file containing model parameters (.pv).

Returns


Leopard.delete()

async delete()

Releases resources acquired by Leopard.


Leopard.sampleRate

get sampleRate()

Getter for audio sample rate accepted by Leopard.

Returns

  • number: Audio sample rate accepted by Leopard.

Leopard.version

get version()

Getter for version.

Returns


Leopard.process()

async process(frame: number[]): Promise<string>

Processes given audio data with the speech-to-text engine. The incoming audio needs to have a sample rate equal to .sampleRate and be 16-bit linearly-encoded. Leopard operates on single-channel audio.

Parameters

  • frame number[] : A frame of audio samples.

Returns

  • Promise<string>: Inferred transcription.

Leopard.processFile()

async processFile(audioPath: string): Promise<string>

Processes an audio file with the speech-to-text engine.

Parameters

  • audioPath string : Absolute path to the audio file. The file needs to have a sample rate equal to or greater than Leopard.sampleRate. The supported formats are: FLAC, MP3, Ogg, Opus, Vorbis, WAV, and WebM.

Returns

  • Promise<string>: Inferred transcription.

LeopardError

class LeopardError extends Error { }

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

Exceptions:

class LeopardActivationError extends LeopardError { }
class LeopardActivationLimitError extends LeopardError { }
class LeopardActivationRefusedError extends LeopardError { }
class LeopardActivationThrottledError extends LeopardError { }
class LeopardIOError extends LeopardError { }
class LeopardInvalidArgumentError extends LeopardError { }
class LeopardInvalidStateError extends LeopardError { }
class LeopardKeyError extends LeopardError { }
class LeopardMemoryError extends LeopardError { }
class LeopardRuntimeError extends LeopardError { }
class LeopardStopIterationError extends LeopardError { }

Issue with this doc? Please let us know.