@picovoice/orca-web
Version:
Orca Text-to-Speech engine for web browsers (via WebAssembly)
134 lines • 6.21 kB
TypeScript
import { OrcaOptions, OrcaModel, OrcaStreamSynthesizeResult, OrcaSynthesizeParams, OrcaSynthesizeResult } from './types';
export interface OrcaStream {
synthesize(text: string): Promise<OrcaStreamSynthesizeResult>;
flush(): Promise<OrcaStreamSynthesizeResult>;
close(): Promise<void>;
}
/**
* JavaScript/WebAssembly Binding for Orca
*/
export declare class Orca {
private readonly _module;
private readonly _pv_orca_synthesize;
private readonly _pv_orca_stream_synthesize;
private readonly _pv_orca_stream_flush;
private readonly _version;
private readonly _sampleRate;
private readonly _validCharacters;
private readonly _maxCharacterLimit;
private readonly _functionMutex;
private readonly _objectAddress;
private readonly _messageStackAddressAddressAddress;
private readonly _messageStackDepthAddress;
private readonly _streamPcmAddressAddress;
private static _wasmSimd;
private static _wasmSimdLib;
private static _wasmPThread;
private static _wasmPThreadLib;
private static _sdk;
private static _orcaMutex;
private constructor();
/**
* Get Orca engine version.
*/
get version(): string;
/**
* Get sample rate.
*/
get sampleRate(): number;
/**
* Get valid characters.
*/
get validCharacters(): string[];
/**
* Get maximum character limit.
*/
get maxCharacterLimit(): number;
/**
* Set base64 wasm file with SIMD feature.
* @param wasmSimd Base64'd wasm file to use to initialize wasm.
*/
static setWasmSimd(wasmSimd: string): void;
/**
* Set base64 SIMD wasm file in text format.
* @param wasmSimdLib Base64'd SIMD wasm file in text format.
*/
static setWasmSimdLib(wasmSimdLib: string): void;
/**
* Set base64 wasm file with SIMD and pthread feature.
* @param wasmPThread Base64'd wasm file to use to initialize wasm.
*/
static setWasmPThread(wasmPThread: string): void;
/**
* Set base64 SIMD and thread wasm file in text format.
* @param wasmPThreadLib Base64'd wasm file in text format.
*/
static setWasmPThreadLib(wasmPThreadLib: string): void;
static setSdk(sdk: string): void;
/**
* Creates an instance of the Picovoice Orca Text-to-Speech 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 Orca model options.
* @param model.base64 The model in base64 string to initialize Orca.
* @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 `orca` 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.device String representation of the device (e.g., CPU or GPU) to use. If set to `best`, the most
* suitable device is selected automatically. If set to `gpu`, the engine uses the first available GPU device. To
* select a specific GPU device, set this argument to `gpu:${GPU_INDEX}`, where `${GPU_INDEX}` is the index of the
* target GPU. If set to `cpu`, the engine will run on the CPU with the default number of threads. To specify the
* number of threads, set this argument to `cpu:${NUM_THREADS}`, where `${NUM_THREADS}` is the desired number of
* threads.
*
* @returns An instance of the Orca engine.
*/
static create(accessKey: string, model: OrcaModel, options?: OrcaOptions): Promise<Orca>;
static _init(accessKey: string, modelPath: string, options?: OrcaOptions): Promise<Orca>;
/**
* Generates audio from text. The returned audio contains the speech representation of the text.
* The maximum number of characters per call to `.synthesize()` is `.maxCharacterLimit`.
* Allowed characters are lower-case and upper-case letters and punctuation marks that can be retrieved with `.validCharacters`.
* Custom pronunciations can be embedded in the text via the syntax `{word|pronunciation}`.
* The pronunciation is expressed in ARPAbet format, e.g.: "I {live|L IH V} in {Sevilla|S EH V IY Y AH}".
*
* @param text A string of text.
* @param synthesizeParams Optional configuration arguments.
* @param synthesizeParams.speechRate Configure the rate of speech of the synthesized speech.
* @param synthesizeParams.randomState Configure the random seed for the synthesized speech.
*
* @return A result object containing the generated audio as a sequence of 16-bit linearly-encoded integers
* and a sequence of OrcaAlignment objects representing the word alignments.
*/
synthesize(text: string, synthesizeParams?: OrcaSynthesizeParams): Promise<OrcaSynthesizeResult>;
/**
* Opens a stream for streaming text synthesis.
*
* @param synthesizeParams Optional configuration arguments.
* @param synthesizeParams.speechRate Configure the rate of speech of the synthesized speech.
* @param synthesizeParams.randomState Configure the random seed for the synthesized speech.
*
* @returns An instance of OrcaStream.
*/
streamOpen(synthesizeParams?: OrcaSynthesizeParams): Promise<OrcaStream>;
/**
* Releases resources acquired by WebAssembly module.
*/
release(): Promise<void>;
private static initWasm;
private static getMessageStack;
/**
* Lists all available devices that Orca can use for inference.
* Each entry in the list can be the used as the `device` argument when calling the `.create` method.
*
* @returns List of all available devices that Orca can use for inference.
*/
static listAvailableDevices(): Promise<string[]>;
private static wrapAsyncFunction;
}
//# sourceMappingURL=orca.d.ts.map