Add support for Azure Speech Service text-to-speech with high-quality neural voices. Features: - Azure TTS provider with 400+ neural voices - Support for 100+ languages and regional accents - High-quality Chinese voices (zh-CN-XiaoxiaoNeural, YunxiNeural, etc.) - Environment variable support: AZURE_SPEECH_API_KEY, AZURE_SPEECH_REGION - Configuration via moltbot.json messages.tts.azure section - SSML-based voice synthesis with proper XML escaping Technical details: - Endpoint: https://{region}.tts.speech.microsoft.com/cognitiveservices/v1 - Headers: Ocp-Apim-Subscription-Key, X-Microsoft-OutputFormat - Request body: SSML XML format - Response: audio/mpeg binary stream - Default: audio-24khz-48kbitrate-mono-mp3 Benefits over Edge TTS: - Higher quality neural voices with better prosody - More voice options (400+ vs limited Edge TTS set) - Unified Azure billing with GPT models - Custom voice support (preview) - Fine-grained SSML control Performance: - Latency: ~500-900ms for typical sentences - Works seamlessly with Telegram voice messages Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
91 lines
2.6 KiB
TypeScript
91 lines
2.6 KiB
TypeScript
export type TtsProvider = "elevenlabs" | "openai" | "edge" | "azure";
|
|
|
|
export type TtsMode = "final" | "all";
|
|
|
|
export type TtsAutoMode = "off" | "always" | "inbound" | "tagged";
|
|
|
|
export type TtsModelOverrideConfig = {
|
|
/** Enable model-provided overrides for TTS. */
|
|
enabled?: boolean;
|
|
/** Allow model-provided TTS text blocks. */
|
|
allowText?: boolean;
|
|
/** Allow model-provided provider override. */
|
|
allowProvider?: boolean;
|
|
/** Allow model-provided voice/voiceId override. */
|
|
allowVoice?: boolean;
|
|
/** Allow model-provided modelId override. */
|
|
allowModelId?: boolean;
|
|
/** Allow model-provided voice settings override. */
|
|
allowVoiceSettings?: boolean;
|
|
/** Allow model-provided normalization or language overrides. */
|
|
allowNormalization?: boolean;
|
|
/** Allow model-provided seed override. */
|
|
allowSeed?: boolean;
|
|
};
|
|
|
|
export type TtsConfig = {
|
|
/** Auto-TTS mode (preferred). */
|
|
auto?: TtsAutoMode;
|
|
/** Legacy: enable auto-TTS when `auto` is not set. */
|
|
enabled?: boolean;
|
|
/** Apply TTS to final replies only or to all replies (tool/block/final). */
|
|
mode?: TtsMode;
|
|
/** Primary TTS provider (fallbacks are automatic). */
|
|
provider?: TtsProvider;
|
|
/** Optional model override for TTS auto-summary (provider/model or alias). */
|
|
summaryModel?: string;
|
|
/** Allow the model to override TTS parameters. */
|
|
modelOverrides?: TtsModelOverrideConfig;
|
|
/** ElevenLabs configuration. */
|
|
elevenlabs?: {
|
|
apiKey?: string;
|
|
baseUrl?: string;
|
|
voiceId?: string;
|
|
modelId?: string;
|
|
seed?: number;
|
|
applyTextNormalization?: "auto" | "on" | "off";
|
|
languageCode?: string;
|
|
voiceSettings?: {
|
|
stability?: number;
|
|
similarityBoost?: number;
|
|
style?: number;
|
|
useSpeakerBoost?: boolean;
|
|
speed?: number;
|
|
};
|
|
};
|
|
/** OpenAI configuration. */
|
|
openai?: {
|
|
apiKey?: string;
|
|
model?: string;
|
|
voice?: string;
|
|
};
|
|
/** Microsoft Edge (node-edge-tts) configuration. */
|
|
edge?: {
|
|
/** Explicitly allow Edge TTS usage (no API key required). */
|
|
enabled?: boolean;
|
|
voice?: string;
|
|
lang?: string;
|
|
outputFormat?: string;
|
|
pitch?: string;
|
|
rate?: string;
|
|
volume?: string;
|
|
saveSubtitles?: boolean;
|
|
proxy?: string;
|
|
timeoutMs?: number;
|
|
};
|
|
/** Azure Speech Service configuration. */
|
|
azure?: {
|
|
apiKey?: string;
|
|
region?: string;
|
|
voice?: string;
|
|
outputFormat?: string;
|
|
lang?: string;
|
|
};
|
|
/** Optional path for local TTS user preferences JSON. */
|
|
prefsPath?: string;
|
|
/** Hard cap for text sent to TTS (chars). */
|
|
maxTextLength?: number;
|
|
/** API request timeout (ms). */
|
|
timeoutMs?: number;
|
|
};
|