UNPKG

@picovoice/cheetah-react-native

Version:

Picovoice Cheetah React Native binding

63 lines (62 loc) 2.92 kB
import type { CheetahOptions, CheetahTranscript } from './cheetah_types'; declare class Cheetah { private readonly _handle; private readonly _frameLength; private readonly _sampleRate; private readonly _version; /** * Static creator for initializing Cheetah given the model path. * @param accessKey AccessKey obtained from Picovoice Console (https://console.picovoice.ai/). * @param modelPath Path to the file containing model parameters. * @param options Optional configuration arguments. * @param options.endpointDuration 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. * @param options.enableAutomaticPunctuation Set to `true` to enable automatic punctuation insertion. * @returns An instance of the engine. */ static create(accessKey: string, modelPath: string, options?: CheetahOptions): Promise<Cheetah>; private constructor(); /** * Process a frame of audio with the speech-to-text engine. * @param frame An array of 16-bit pcm samples. The number of samples per frame can be attained by calling * `Cheetah.frameLength`. The incoming audio needs to have a sample rate equal to `Cheetah.sampleRate` * and be 16-bit linearly-encoded. Furthermore, Cheetah operates on single-channel audio. * @returns {Promise<CheetahTranscript>} transcript 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. */ process(frame: number[]): Promise<CheetahTranscript>; /** * Marks the end of the audio stream, flushes internal state of the object, and returns * any remaining transcribed text. * * @returns {Promise<CheetahTranscript>} Any remaining transcribed text. If none is available then an empty string is returned. */ flush(): Promise<CheetahTranscript>; /** * Frees memory that was allocated for Cheetah */ delete(): Promise<any>; /** * Gets the required number of audio samples per frame. * @returns Required frame length. */ get frameLength(): number; /** * Get the audio sample rate required by Cheetah. * @returns Required sample rate. */ get sampleRate(): number; /** * Gets the version number of the Cheetah library. * @returns Version of Cheetah */ get version(): string; /** * Gets the Error type given a code. * @param code Code name of native Error. * @param message Detailed message of the error. */ private static codeToError; } export default Cheetah;