react-nativeCheetah Platform — React Native API

API Reference for the React Native Cheetah SDK (npm)


Cheetah

class Cheetah { }

Class for the Cheetah Speech-to-Text engine.


Cheetah.create()

public static async create(
accessKey: string,
modelPath: string,
endpointDuration: number = 1.0
): Promise<Cheetah>

Cheetah constructor.

Parameters

  • accessKey string : AccessKey obtained from Picovoice Console.
  • modelPath string : Path to the file containing model parameters (.pv).
  • endpointDuration number : Duration of endpoint in seconds. A speech endpoint is detected when there is a chunk of audio (with a duration specified herein) after an utterance without any speech in it. Set duration to 0 to disable this. Default is 1 second.

Returns


Cheetah.delete()

async delete()

Releases resources acquired by Cheetah.


Cheetah.frameLength

get frameLength()

Getter for number of audio samples per frame.

Returns

  • number: Number of audio samples per frame.

Cheetah.sampleRate

get sampleRate()

Getter for audio sample rate accepted by Cheetah.

Returns

  • number: Audio sample rate accepted by Cheetah.

Cheetah.version

get version()

Getter for version.

Returns


Cheetah.process()

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

Processes a frame of the incoming audio stream with the speech-to-text engine. The number of samples per frame can be attained by calling .frameLength. The incoming audio needs to have a sample rate equal to .sampleRate and be 16-bit linearly-encoded. Cheetah operates on single-channel audio.

Parameters

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

Returns

  • Promise<[string, boolean]>: Transcription of any newly-transcribed speech (if none is available then an empty string is returned) and a flag indicating if an endpoint has been detected.

Cheetah.flush()

async flush(): Promise<string>

Marks the end of the audio stream, flushes internal state of the object, and returns any remaining transcribed text.

Returns

  • Promise<string>: Any remaining transcribed text. If none is available then an empty string is returned.

CheetahError

class CheetahError extends Error { }

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

Exceptions:

class CheetahActivationError extends CheetahError { }
class CheetahActivationLimitError extends CheetahError { }
class CheetahActivationRefusedError extends CheetahError { }
class CheetahActivationThrottledError extends CheetahError { }
class CheetahIOError extends CheetahError { }
class CheetahInvalidArgumentError extends CheetahError { }
class CheetahInvalidStateError extends CheetahError { }
class CheetahKeyError extends CheetahError { }
class CheetahMemoryError extends CheetahError { }
class CheetahRuntimeError extends CheetahError { }
class CheetahStopIterationError extends CheetahError { }

Issue with this doc? Please let us know.