UNPKG

edge-tts-universal

Version:

Universal text-to-speech library using Microsoft Edge's online TTS service. Works in Node.js and browsers WITHOUT needing Microsoft Edge, Windows, or an API key

90 lines (87 loc) 3.04 kB
export { I as Communicate, c as CommunicateOptions, C as CommunicateState, e as DRM, E as EdgeTTSException, F as FetchError, N as NoAudioReceived, f as SkewAdjustmentError, S as SubMaker, T as TTSChunk, g as UnexpectedResponse, U as UnknownResponse, h as ValueError, V as Voice, i as VoiceTag, d as VoicesManager, a as VoicesManagerFind, b as VoicesManagerVoice, W as WebSocketError, l as listVoices } from './exceptions-C4rAyGjr.cjs'; /** * Options for controlling the voice prosody (rate, pitch, volume). */ interface ProsodyOptions { /** * The speaking rate of the voice. * Examples: "+10.00%", "-20.00%" */ rate?: string; /** * The speaking volume of the voice. * Examples: "+15.00%", "-10.00%" */ volume?: string; /** * The speaking pitch of the voice. * Examples: "+20Hz", "-10Hz" */ pitch?: string; } /** * Represents a single word boundary with its timing and text. * The API provides timing in 100-nanosecond units. */ interface WordBoundary { /** * The offset from the beginning of the audio stream in 100-nanosecond units. */ offset: number; /** * The duration of the word in 100-nanosecond units. */ duration: number; /** * The text of the spoken word. */ text: string; } /** * The final result of the synthesis process. */ interface SynthesisResult { /** * The generated audio as a Blob, which can be used in an <audio> element. */ audio: Blob; /** * An array of word boundaries containing timing and text for creating subtitles. */ subtitle: WordBoundary[]; } /** * Isomorphic Edge TTS class that works in both Node.js and browser environments. * Uses isomorphic implementations to avoid platform-specific dependencies. */ declare class IsomorphicEdgeTTS { text: string; voice: string; rate: string; volume: string; pitch: string; /** * @param text The text to be synthesized. * @param voice The voice to use for synthesis. * @param options Prosody options (rate, volume, pitch). */ constructor(text: string, voice?: string, options?: ProsodyOptions); /** * Initiates the synthesis process using isomorphic implementations. * @returns A promise that resolves with the synthesized audio and subtitle data. */ synthesize(): Promise<SynthesisResult>; } /** * Creates a subtitle file content in VTT (WebVTT) format. * @param wordBoundaries The array of word boundary data. * @returns A string containing the VTT formatted subtitles. */ declare function createVTT(wordBoundaries: WordBoundary[]): string; /** * Creates a subtitle file content in SRT (SubRip) format. * @param wordBoundaries The array of word boundary data. * @returns A string containing the SRT formatted subtitles. */ declare function createSRT(wordBoundaries: WordBoundary[]): string; export { IsomorphicEdgeTTS as EdgeTTS, type ProsodyOptions, type SynthesisResult, type WordBoundary, createSRT, createVTT };