UNPKG

openvino-genai-node

Version:

OpenVINO™ GenAI pipelines for using from Node.js environment

53 lines (52 loc) 2.19 kB
import { Tensor } from "openvino-node"; import { Text2SpeechPipeline as Text2SpeechPipelineWrapper } from "../addon.js"; import { Text2SpeechDecodedResults } from "../decodedResults.js"; import { SpeechGenerationConfig, Text2SpeechPipelineProperties } from "../utils.js"; /** * Options for Text2Speech generation methods. */ export type Text2SpeechGenerateOptions = { /** Optional speaker embedding tensor to condition voice characteristics. */ speakerEmbedding?: Tensor; /** Additional generation properties passed to the native pipeline. */ generationConfig?: SpeechGenerationConfig; }; /** * Pipeline for text-to-speech synthesis. * * Converts text input into audio waveform tensors. * Use the factory method `PipelineFactory.Text2SpeechPipeline()` to create and * initialize an instance. */ export declare class Text2SpeechPipeline { protected readonly modelPath: string; protected readonly device: string; protected pipeline: Text2SpeechPipelineWrapper | null; protected readonly properties: Text2SpeechPipelineProperties; /** * Construct a Text2Speech pipeline from a folder containing model IRs. * @param modelPath - Path to the folder with model IRs. * @param device - Inference device (e.g. "CPU", "GPU"). * @param properties - Device and pipeline properties. */ constructor(modelPath: string, device: string, properties?: Text2SpeechPipelineProperties); /** * Load the pipeline. Must be called once before generate(). */ init(): Promise<void>; /** * Generate audio from a single text or batch of texts. * @param input - Text string or array of text strings to synthesize. * @param options - Optional speaker embedding and generation config. * @returns Decoded results with audio waveform tensors and perf metrics. */ generate(input: string | string[], options?: Text2SpeechGenerateOptions): Promise<Text2SpeechDecodedResults>; /** * Get current speech generation config. */ getGenerationConfig(): SpeechGenerationConfig; /** * Update speech generation config. */ setGenerationConfig(config: SpeechGenerationConfig): void; }