expo-edge-speech
Version:
Text-to-speech library for Expo using Microsoft Edge TTS service
112 lines • 3.26 kB
TypeScript
/**
* Creates voice management and caching service using network and storage services.
* Fetches available voices, transforms Edge TTS voice data to expo-speech format,
* implements voice list caching with TTL, provides voice search and filtering
* functionality, and handles multilingual voice capabilities.
*/
import type { EdgeSpeechVoice, SpeechVoiceConfig } from "../types";
/**
* Voice filtering options
*/
interface VoiceFilterOptions {
language?: string;
gender?: "Male" | "Female";
contentCategories?: string[];
voicePersonalities?: string[];
}
/**
* Voice management and caching service
* Handles voice fetching, transformation, caching, and filtering
*/
export declare class VoiceService {
private static instance;
/** Storage service for caching */
private storageService;
/** Voice cache */
private voiceCache;
/** Service configuration */
private config;
/** Debug logging flag */
private debugLog;
constructor(config?: Partial<SpeechVoiceConfig>);
/**
* Get singleton instance of voice service
*/
static getInstance(config?: Partial<SpeechVoiceConfig>): VoiceService;
/**
* Get available voices with caching
* Fetches from cache if available and not expired, otherwise fetches from network
*/
getAvailableVoices(): Promise<EdgeSpeechVoice[]>;
/**
* Search and filter voices
*/
getFilteredVoices(filterOptions: VoiceFilterOptions): Promise<EdgeSpeechVoice[]>;
/**
* Find voice by identifier
*/
findVoiceByIdentifier(identifier: string): Promise<EdgeSpeechVoice | null>;
/**
* Validate voice selection
*/
validateVoiceSelection(voiceIdentifier: string): Promise<{
isValid: boolean;
voice?: EdgeSpeechVoice;
suggestions?: EdgeSpeechVoice[];
}>;
/**
* Get voices by language
*/
getVoicesByLanguage(language: string): Promise<EdgeSpeechVoice[]>;
/**
* Get default voice for language
*/
getDefaultVoiceForLanguage(language: string): Promise<EdgeSpeechVoice | null>;
/**
* Refresh voice cache
* Forces a fresh fetch from the network
*/
refreshVoiceCache(): Promise<EdgeSpeechVoice[]>;
/**
* Check if voice cache is valid (exists and not expired)
*/
private isVoiceCacheValid;
/**
* Update voice cache with new data
*/
private updateVoiceCache;
/**
* Fetch voices from Edge TTS network service
*/
private fetchVoicesFromNetwork;
/**
* Transform Edge TTS voice data to EdgeSpeechVoice format
*/
private transformEdgeVoicesToExpoFormat;
/**
* Debug logging helper
*/
private log;
/**
* Get service statistics
*/
getStats(): {
cacheValid: boolean;
cacheExpiration: Date | null;
cachedVoiceCount: number;
cacheTimestamp: Date | null;
};
/**
* Initialize the service (for StateManager integration)
*/
initialize(): Promise<void>;
/**
* Cleanup the service (for StateManager integration)
*/
cleanup(): Promise<void>;
}
/**
* Default voice service instance
*/
export default VoiceService;
//# sourceMappingURL=voiceService.d.ts.map