edge-tts-client
Version:
Client-side (web browser) implementation of Edge TTS package — Microsoft Edge Read Aloud API called to generate free text-to-speech
57 lines (56 loc) • 1.68 kB
TypeScript
import type { PITCH, RATE, VOLUME } from './constants';
import { OUTPUT_FORMAT } from './constants';
type EventType = "data" | "close" | "end";
declare class EventEmitter {
private eventListeners;
constructor();
on(event: EventType, callback: (...args: any[]) => void): void;
emit(event: EventType, data: any): void;
}
export type Voice = {
Name: string;
ShortName: string;
Gender: string;
Locale: string;
SuggestedCodec: string;
FriendlyName: string;
Status: string;
};
export declare class ProsodyOptions {
pitch: PITCH | string;
rate: RATE | string | number;
volume: VOLUME | string | number;
}
export declare class EdgeTTSClient {
static OUTPUT_FORMAT: typeof OUTPUT_FORMAT;
private static CLIENT_TOKEN;
private static VOICES_URL;
private static SYNTH_URL;
private static BINARY_DELIM;
private static VOICE_LANG_REGEX;
private enableLogging;
private isBrowser;
private ws;
private voice;
private voiceLocale;
private outputFormat;
private requestQueue;
private connectionStartTime;
constructor(enableLogging?: boolean);
private log;
private sendMessage;
private initWebSocket;
private handleMessage;
private handleClose;
private cacheAudioData;
private findDelimiterIndex;
private getConfigMessage;
getVoices(): Promise<Voice[]>;
setMetadata(voiceName: string, outputFormat: OUTPUT_FORMAT, voiceLocale?: string): Promise<void>;
private inferLocaleFromVoiceName;
close(): void;
toStream(text: string, options?: ProsodyOptions): EventEmitter;
private buildSSML;
private sendSSMLRequest;
}
export {};