@picovoice/koala-web
Version:
Koala Noise Suppression engine for web browsers (via WebAssembly)
105 lines • 4.8 kB
TypeScript
import { KoalaModel, KoalaOptions } from './types';
export declare class Koala {
private readonly _pvKoalaDelete;
private readonly _pvKoalaProcess;
private readonly _pvKoalaReset;
private readonly _pvStatusToString;
private readonly _pvGetErrorStack;
private readonly _pvFreeErrorStack;
private _wasmMemory;
private readonly _pvFree;
private readonly _processMutex;
private readonly _objectAddress;
private readonly _inputBufferAddress;
private readonly _outputBufferAddress;
private readonly _messageStackAddressAddressAddress;
private readonly _messageStackDepthAddress;
private static _delaySample;
private static _frameLength;
private static _sampleRate;
private static _version;
private static _wasm;
private static _wasmSimd;
private static _sdk;
private static _koalaMutex;
private readonly _processCallback;
private readonly _processErrorCallback?;
private readonly _pvError;
private constructor();
static setSdk(sdk: string): void;
/**
* Delay in samples. If the input and output of consecutive calls to `.process()` are viewed as two contiguous
* streams of audio data, this delay specifies the time shift between the input and output stream.
*/
get delaySample(): number;
/**
* Get Koala engine version.
*/
get version(): string;
/**
* Get frame length.
*/
get frameLength(): number;
/**
* 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;
/**
* Creates an instance of the Picovoice Koala Noise Suppression 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 processCallback User-defined callback to run after receiving enhanced pcm result.
* The output is not directly the enhanced version of the input PCM, but corresponds to samples that were given in
* previous calls to `.process()`. The delay in samples between the start time of the input frame and the start
* time of the output frame can be attained from `.delaySample`.
* @param model Koala model options.
* @param model.base64 The model in base64 string to initialize Koala.
* @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 `koala` 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 configuration arguments.
* @param options.processErrorCallback User-defined callback invoked if any error happens
* while processing the audio stream. Its only input argument is the error message.
*
* @returns An instance of the Koala engine.
*/
static create(accessKey: string, processCallback: (enhancedPcm: Int16Array) => void, model: KoalaModel, options?: KoalaOptions): Promise<Koala>;
static _init(accessKey: string, processCallback: (enhancedPcm: Int16Array) => void, modelPath: string, options?: KoalaOptions): Promise<Koala>;
/**
* Processes a frame of audio. The required sample rate can be retrieved from '.sampleRate' and the length
* of frame (number of audio samples per frame) can be retrieved from '.frameLength' The audio needs to be
* 16-bit linearly-encoded. Furthermore, the engine operates on single-channel audio. Consecutive calls to
* `.process()` must provide consecutive frames of audio from the same source, unless `.reset()` has been
* called in between.
*
* @param pcm A frame of audio with properties described above.
*/
process(pcm: Int16Array): Promise<void>;
/**
* Resets Koala into a state as if it had just been newly created.
* Call this function in between calls to `process` that do not provide consecutive frames of audio.
*/
reset(): Promise<void>;
/**
* Releases resources acquired by WebAssembly module.
*/
release(): Promise<void>;
onmessage(e: MessageEvent): Promise<void>;
private static initWasm;
private static getMessageStack;
}
//# sourceMappingURL=koala.d.ts.map