UNPKG

js-tts-wrapper

Version:

A JavaScript/TypeScript library that provides a unified API for working with multiple cloud-based Text-to-Speech (TTS) services

48 lines (47 loc) 1.67 kB
import { AbstractTTSClient } from "../core/abstract-tts"; import type { SpeakOptions, TTSCredentials, UnifiedVoice } from "../types"; export interface UnrealSpeechTTSOptions extends SpeakOptions { voice?: string; audioFormat?: "mp3" | "wav" | "pcm"; providerOptions?: Record<string, unknown>; } export interface UnrealSpeechTTSCredentials extends TTSCredentials { apiKey?: string; baseURL?: string; properties?: Record<string, unknown> | string; propertiesJson?: string; } export declare class UnrealSpeechTTSClient extends AbstractTTSClient { private apiKey; private baseUrl; static readonly VOICES: ({ id: string; name: string; gender: "Female"; language: string; } | { id: string; name: string; gender: "Male"; language: string; })[]; constructor(credentials?: UnrealSpeechTTSCredentials); private applyCredentialProperties; private prepareText; setVoice(voiceId: string): void; getProperty(property: string): any; setProperty(property: string, value: any): void; checkCredentials(): Promise<boolean>; protected getRequiredCredentials(): string[]; protected _getVoices(): Promise<any[]>; protected _mapVoicesToUnified(rawVoices: any[]): Promise<UnifiedVoice[]>; synthToBytes(text: string, options?: UnrealSpeechTTSOptions): Promise<Uint8Array>; synthToBytestream(text: string, options?: UnrealSpeechTTSOptions): Promise<{ audioStream: ReadableStream<Uint8Array>; wordBoundaries: Array<{ text: string; offset: number; duration: number; }>; }>; }