@picovoice/leopard-react-native
Version:
Picovoice Leopard React Native binding
55 lines (54 loc) • 2.63 kB
TypeScript
import type { LeopardTranscript, LeopardOptions } from './leopard_types';
declare class Leopard {
private readonly _handle;
private readonly _sampleRate;
private readonly _version;
/**
* Static creator for initializing Leopard 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.enableAutomaticPunctuation Set to `true` to enable automatic punctuation insertion.
* @param options.enableDiarization Set to `true` to enable speaker diarization, which allows Leopard to differentiate speakers
* as part of the transcription process. Word metadata will include a `speakerTag` to identify unique speakers.
* @returns An instance of the engine.
*/
static create(accessKey: string, modelPath: string, options?: LeopardOptions): Promise<Leopard>;
private constructor();
/**
* Process a frame of audio with the speech-to-text engine.
* @param frame An array of 16-bit pcm samples. The audio needs to have a sample rate equal to `.sampleRate` 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 `.processFile`.
* @returns {Promise<LeopardTranscript>} LeopardTranscript object which contains the transcription results of the engine.
*/
process(frame: number[]): Promise<LeopardTranscript>;
/**
* Process a frame of audio with the speech-to-text engine.
* @param audioPath Absolute path to the audio file. The supported formats are: `3gp (AMR)`, `FLAC`, `MP3`,
* `MP4/m4a (AAC)`, `Ogg`, `WAV` and `WebM`.
* @returns {Promise<LeopardTranscript>>} LeopardTranscript object which contains the transcription results of the engine.
*/
processFile(audioPath: string): Promise<LeopardTranscript>;
/**
* Frees memory that was allocated for Leopard
*/
delete(): Promise<any>;
/**
* Get the audio sample rate required by Leopard.
* @returns Required sample rate.
*/
get sampleRate(): number;
/**
* Gets the version number of the Leopard library.
* @returns Version of Leopard
*/
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 Leopard;