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

111 lines (110 loc) 2.95 kB
/** * SSML Compatibility Layer * * This module provides cross-engine SSML compatibility by: * 1. Validating SSML structure * 2. Converting SSML to engine-specific formats * 3. Providing fallbacks for unsupported features * 4. Ensuring proper SSML nesting and structure */ export interface SSMLCapabilities { supportsSSML: boolean; supportLevel: "full" | "limited" | "none"; supportedTags: string[]; unsupportedTags: string[]; requiresNamespace: boolean; requiresVersion: boolean; maxNestingDepth?: number; } export interface SSMLValidationResult { isValid: boolean; errors: string[]; warnings: string[]; processedSSML?: string; } /** * SSML capabilities for different TTS engines */ export declare const ENGINE_SSML_CAPABILITIES: Record<string, SSMLCapabilities>; /** * Voice-specific SSML capabilities for engines with dynamic support */ export declare const VOICE_SPECIFIC_CAPABILITIES: { polly: { standard: { supportLevel: "full"; unsupportedTags: never[]; }; "long-form": { supportLevel: "full"; unsupportedTags: never[]; }; neural: { supportLevel: "limited"; unsupportedTags: string[]; }; generative: { supportLevel: "limited"; unsupportedTags: string[]; }; }; google: { standard: { supportLevel: "full"; unsupportedTags: never[]; }; wavenet: { supportLevel: "full"; unsupportedTags: never[]; }; neural2: { supportLevel: "limited"; unsupportedTags: string[]; }; journey: { supportLevel: "none"; unsupportedTags: string[]; }; studio: { supportLevel: "none"; unsupportedTags: string[]; }; }; }; /** * SSML Compatibility Manager */ export declare class SSMLCompatibilityManager { /** * Get SSML capabilities for a specific engine and voice */ static getCapabilities(engine: string, voiceId?: string): SSMLCapabilities; /** * Get voice-specific SSML capabilities */ private static getVoiceSpecificCapabilities; /** * Detect voice type from voice ID */ private static detectVoiceType; /** * Validate SSML for a specific engine */ static validateSSML(ssml: string, engine: string, voiceId?: string): SSMLValidationResult; /** * Process SSML for engine compatibility */ static processSSMLForEngine(ssml: string, engine: string, voiceId?: string): string; /** * Strip all SSML tags from text */ private static stripAllSSMLTags; /** * Remove specific SSML tag */ private static removeSSMLTag; /** * Add required attributes to SSML */ private static addRequiredAttributes; }