@picovoice/leopard-web
Version:
Leopard Speech-to-Text engine for web browsers (via WebAssembly)
82 lines • 3.57 kB
TypeScript
import { LeopardModel, LeopardOptions, LeopardTranscript } from './types';
export declare class Leopard {
private readonly _pvLeopardDelete;
private readonly _pvLeopardTranscriptDelete;
private readonly _pvLeopardWordsDelete;
private readonly _pvLeopardProcess;
private readonly _pvGetErrorStack;
private readonly _pvFreeErrorStack;
private _wasmMemory?;
private readonly _pvFree;
private readonly _processMutex;
private readonly _objectAddress;
private readonly _alignedAlloc;
private readonly _transcriptAddressAddress;
private readonly _numWordsAddress;
private readonly _wordsAddressAddress;
private readonly _messageStackAddressAddressAddress;
private readonly _messageStackDepthAddress;
private static _sampleRate;
private static _version;
private static _wasm;
private static _wasmSimd;
private static _sdk;
private static _leopardMutex;
private constructor();
/**
* Get Leopard engine version.
*/
get version(): string;
/**
* Get sample rate.
*/
get sampleRate(): number;
/**
* Set base64 wasm file.
* @param wasm Base64'd wasm file to use to initialize wasm.
*/
static setWasm(wasm: string): void;
/**
* Set base64 wasm file with SIMD feature.
* @param wasmSimd Base64'd wasm file to use to initialize wasm.
*/
static setWasmSimd(wasmSimd: string): void;
static setSdk(sdk: string): void;
/**
* Creates an instance of the Picovoice Leopard Speech-to-Text engine.
* Behind the scenes, it requires the WebAssembly code to load and initialize before
* it can create an instance.
*
* @param accessKey AccessKey obtained from Picovoice Console (https://console.picovoice.ai/)
* @param model Leopard model options.
* @param model.base64 The model in base64 string to initialize Leopard.
* @param model.publicPath The model path relative to the public directory.
* @param model.customWritePath Custom path to save the model in storage.
* Set to a different name to use multiple models across `leopard` instances.
* @param model.forceWrite Flag to overwrite the model in storage even if it exists.
* @param model.version Version of the model file. Increment to update the model file in storage.
* @param options Optional arguments.
* @param options.enableAutomaticPunctuation Flag to enable automatic punctuation insertion.
* @param options.enableDiarization Flag 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 Leopard engine.
*/
static create(accessKey: string, model: LeopardModel, options?: LeopardOptions): Promise<Leopard>;
static _init(accessKey: string, modelPath: string, options?: LeopardOptions): Promise<Leopard>;
/**
* Processes audio. The required sample rate can be retrieved from '.sampleRate'. The audio needs to be
* 16-bit linearly-encoded. Furthermore, the engine operates on single-channel audio.
*
* @param pcm A frame of audio with properties described above.
* @return The transcript.
*/
process(pcm: Int16Array): Promise<LeopardTranscript>;
/**
* Releases resources acquired by WebAssembly module.
*/
release(): Promise<void>;
private static initWasm;
private static getMessageStack;
}
//# sourceMappingURL=leopard.d.ts.map