@picovoice/orca-web
Version:
Orca Text-to-Speech engine for web browsers (via WebAssembly)
120 lines • 5.06 kB
TypeScript
import { 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 _wasm;
private static _wasmLib;
private static _wasmSimd;
private static _wasmSimdLib;
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.
* @param wasm Base64'd wasm file to use to initialize wasm.
*/
static setWasm(wasm: string): void;
/**
* Set base64 wasm file in text format.
* @param wasmLib Base64'd wasm file in text format.
*/
static setWasmLib(wasmLib: 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;
/**
* Set base64 SIMD wasm file in text format.
* @param wasmSimdLib Base64'd SIMD wasm file in text format.
*/
static setWasmSimdLib(wasmSimdLib: 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.
*
* @returns An instance of the Orca engine.
*/
static create(accessKey: string, model: OrcaModel): Promise<Orca>;
static _init(accessKey: string, modelPath: string): 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;
private static wrapAsyncFunction;
}
//# sourceMappingURL=orca.d.ts.map