type TTSChunk = { type: "audio" | "WordBoundary"; data?: Buffer; duration?: number; offset?: number; text?: string; }; type VoiceTag = { ContentCategories: ("Cartoon" | "Conversation" | "Copilot" | "Dialect" | "General" | "News" | "Novel" | "Sports")[]; VoicePersonalities: ("Approachable" | "Authentic" | "Authority" | "Bright" | "Caring" | "Casual" | "Cheerful" | "Clear" | "Comfort" | "Confident" | "Considerate" | "Conversational" | "Cute" | "Expressive" | "Friendly" | "Honest" | "Humorous" | "Lively" | "Passion" | "Pleasant" | "Positive" | "Professional" | "Rational" | "Reliable" | "Sincere" | "Sunshine" | "Warm")[]; }; type Voice = { Name: string; ShortName: string; Gender: "Female" | "Male"; Locale: string; SuggestedCodec: "audio-24khz-48kbitrate-mono-mp3"; FriendlyName: string; Status: "GA"; VoiceTag: VoiceTag; }; type VoicesManagerVoice = Voice & { Language: string; }; type VoicesManagerFind = { Gender?: "Female" | "Male"; Locale?: string; Language?: string; }; type CommunicateState = { partialText: Buffer; offsetCompensation: number; lastDurationOffset: number; streamWasCalled: boolean; }; /** * Configuration options for the Communicate class. */ interface CommunicateOptions { /** Voice to use for synthesis (e.g., "en-US-EmmaMultilingualNeural") */ voice?: string; /** Speech rate adjustment (e.g., "+20%", "-10%") */ rate?: string; /** Volume level adjustment (e.g., "+50%", "-25%") */ volume?: string; /** Pitch adjustment in Hz (e.g., "+5Hz", "-10Hz") */ pitch?: string; /** Proxy URL for requests */ proxy?: string; /** WebSocket connection timeout in milliseconds */ connectionTimeout?: number; } /** * Main class for text-to-speech synthesis using Microsoft Edge's online TTS service. * * @example * ```typescript * const communicate = new Communicate('Hello, world!', { * voice: 'en-US-EmmaMultilingualNeural', * }); * * for await (const chunk of communicate.stream()) { * if (chunk.type === 'audio' && chunk.data) { * // Handle audio data * } * } * ``` */ declare class Communicate { private readonly ttsConfig; private readonly texts; private readonly proxy?; private readonly connectionTimeout?; private state; /** * Creates a new Communicate instance for text-to-speech synthesis. * * @param text - The text to synthesize * @param options - Configuration options for synthesis */ constructor(text: string, options?: CommunicateOptions); private parseMetadata; private _stream; /** * Streams text-to-speech synthesis results. * * Returns an async generator that yields audio chunks and word boundary events. * Can only be called once per Communicate instance. * * @yields TTSChunk - Audio data or word boundary information * @throws {Error} If called more than once * @throws {NoAudioReceived} If no audio data is received * @throws {WebSocketError} If WebSocket connection fails * * @example * ```typescript * for await (const chunk of communicate.stream()) { * if (chunk.type === 'audio') { * // Process audio data * } else if (chunk.type === 'WordBoundary') { * // Process subtitle timing * } * } * ``` */ stream(): AsyncGenerator; } /** * Utility class for generating SRT subtitles from WordBoundary events. * * @example * ```typescript * const subMaker = new SubMaker(); * * for await (const chunk of communicate.stream()) { * if (chunk.type === 'WordBoundary') { * subMaker.feed(chunk); * } * } * * const srt = subMaker.getSrt(); * ``` */ declare class SubMaker { private cues; /** * Adds a WordBoundary chunk to the subtitle maker. * * @param msg - Must be a WordBoundary type chunk with offset, duration, and text * @throws {ValueError} If chunk is not a WordBoundary with required fields */ feed(msg: TTSChunk): void; mergeCues(words: number): void; /** * Returns the subtitles in SRT format. * * @returns SRT formatted subtitles */ getSrt(): string; toString(): string; } /** * Fetches all available voices from the Microsoft Edge TTS service. * * @param proxy - Optional proxy URL for the request * @returns Promise resolving to array of available voices */ declare function listVoices(proxy?: string): Promise; /** * Utility class for finding and filtering available voices. * * @example * ```typescript * const voicesManager = await VoicesManager.create(); * const englishVoices = voicesManager.find({ Language: 'en' }); * ``` */ declare class VoicesManager { private voices; private calledCreate; /** * Creates a new VoicesManager instance. * * @param customVoices - Optional custom voice list instead of fetching from API * @param proxy - Optional proxy URL for API requests * @returns Promise resolving to VoicesManager instance */ static create(customVoices?: Voice[], proxy?: string): Promise; /** * Finds voices matching the specified criteria. * * @param filter - Filter criteria for voice selection * @returns Array of voices matching the filter * @throws {Error} If called before create() */ find(filter: VoicesManagerFind): VoicesManagerVoice[]; } declare class EdgeTTSException extends Error { constructor(message: string); } declare class SkewAdjustmentError extends EdgeTTSException { constructor(message: string); } declare class UnknownResponse extends EdgeTTSException { constructor(message: string); } declare class UnexpectedResponse extends EdgeTTSException { constructor(message: string); } declare class NoAudioReceived extends EdgeTTSException { constructor(message: string); } declare class WebSocketError extends EdgeTTSException { constructor(message: string); } declare class ValueError extends EdgeTTSException { constructor(message: string); } /** * 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