expo-edge-speech
Version:
Text-to-speech library for Expo using Microsoft Edge TTS service
94 lines • 2.96 kB
TypeScript
/**
* SSML generation and processing utilities for EdgeSpeech
*/
import { SpeechOptions, EdgeSpeechVoice } from "../types";
/**
* SSML validation result interface
*/
export interface SSMLValidationResult {
isValid: boolean;
errors: string[];
warnings: string[];
}
/**
* Required SSML namespace and attributes
*/
export declare const SSML_CONSTANTS: {
readonly VERSION: "1.0";
readonly XMLNS: "http://www.w3.org/2001/10/synthesis";
readonly XMLNS_MSTTS: "https://www.w3.org/2001/mstts";
readonly DEFAULT_LANG: "en-US";
};
/**
* Escape XML special characters for SSML content
*/
export declare function escapeXML(text: string): string;
/**
* Validate voice name against available voices
*/
export declare function validateVoiceName(voiceName: string, availableVoices?: EdgeSpeechVoice[]): {
isValid: boolean;
suggestion?: string;
};
/**
* Format pitch parameter for Edge TTS
*/
export declare function formatPitch(pitchInput?: number): string;
/**
* Format rate parameter for Edge TTS
*/
export declare function formatRate(rateInput?: number): string;
/**
* Format volume parameter for Edge TTS
*/
export declare function formatVolume(volumeInput?: number): string;
/**
* Extract language from voice identifier
*/
export declare function extractLanguageFromVoice(voiceIdentifier: string): string;
/**
* Convert voice identifier to Microsoft Edge TTS format
*/
export declare function formatVoiceNameForEdgeTTS(voiceIdentifier: string): string;
/**
* Validate SSML markup structure
*/
export declare function validateSSML(ssml: string): SSMLValidationResult;
/**
* Generate SSML with enhanced validation and voice handling
*/
export declare function generateSSMLWithValidation(text: string, options?: SpeechOptions, availableVoices?: EdgeSpeechVoice[]): {
ssml: string;
validation: SSMLValidationResult;
};
/**
* Generates the required SSML for Microsoft Edge TTS
* @throws Error if text is invalid, exceeds max length.
*/
export declare function generateSSML(text: string, options?: SpeechOptions): string;
/**
* Enhanced SSML generation with additional elements support
* @throws Error if text is invalid, exceeds max length, or if voice is not provided.
*/
export declare function generateEnhancedSSML(text: string, options: SSMLGenerationOptions): string;
/**
* Check if a string appears to be valid SSML
*/
export declare function isValidSSML(content: string): boolean;
/**
* Extract text content from SSML markup
*/
export declare function extractTextFromSSML(ssml: string): string;
/**
* Normalize SSML formatting for consistent output
*/
export declare function normalizeSSML(ssml: string): string;
/**
* Enhanced SSML generation with support for additional elements
*/
export interface SSMLGenerationOptions extends SpeechOptions {
prefixElements?: string[];
suffixElements?: string[];
useMicrosoftVoiceFormat?: boolean;
}
//# sourceMappingURL=ssmlUtils.d.ts.map