|
|
""" |
|
|
DungeonMaster AI - Voice Package |
|
|
|
|
|
ElevenLabs integration for voice synthesis and narration. |
|
|
|
|
|
This module provides: |
|
|
- VoiceClient: Production-ready ElevenLabs client with circuit breaker |
|
|
- NarrationProcessor: Text preprocessing for optimal TTS |
|
|
- Voice profiles: Pre-configured voices for DM, NPCs, and monsters |
|
|
- Comprehensive error handling and graceful degradation |
|
|
|
|
|
Example Usage: |
|
|
```python |
|
|
from src.voice import VoiceClient, NarrationProcessor, VoiceType |
|
|
|
|
|
# Initialize client |
|
|
client = VoiceClient() |
|
|
await client.initialize() |
|
|
|
|
|
# Process and synthesize |
|
|
processor = NarrationProcessor() |
|
|
processed = processor.process_for_tts("Roll a 1d20 for HP!") |
|
|
|
|
|
if client.is_available: |
|
|
audio = await client.synthesize(processed, VoiceType.DM) |
|
|
``` |
|
|
""" |
|
|
|
|
|
|
|
|
from src.voice.exceptions import ( |
|
|
VoiceAPIError, |
|
|
VoiceAuthenticationError, |
|
|
VoiceCircuitBreakerOpenError, |
|
|
VoiceConfigurationError, |
|
|
VoiceIntegrationError, |
|
|
VoiceNotFoundError, |
|
|
VoiceQuotaExhaustedError, |
|
|
VoiceRateLimitError, |
|
|
VoiceSynthesisError, |
|
|
VoiceUnavailableError, |
|
|
) |
|
|
|
|
|
|
|
|
from src.voice.models import ( |
|
|
NarrationResult, |
|
|
ProcessedNarration, |
|
|
SynthesisRequest, |
|
|
SynthesisResult, |
|
|
TextSegment, |
|
|
VoiceCircuitState, |
|
|
VoiceModelType, |
|
|
VoiceProfile, |
|
|
VoiceServiceState, |
|
|
VoiceServiceStatus, |
|
|
VoiceSynthesisSettings, |
|
|
VoiceType, |
|
|
) |
|
|
|
|
|
|
|
|
from src.voice.voice_profiles import ( |
|
|
VOICE_PROFILES, |
|
|
get_all_profiles, |
|
|
get_voice_id, |
|
|
get_voice_profile, |
|
|
get_voice_profile_by_name, |
|
|
get_voice_settings, |
|
|
reset_profiles_cache, |
|
|
select_voice_for_context, |
|
|
select_voice_from_game_context, |
|
|
select_voice_from_npc_data, |
|
|
) |
|
|
|
|
|
|
|
|
from src.voice.text_processor import NarrationProcessor |
|
|
|
|
|
|
|
|
from src.voice.elevenlabs_client import ( |
|
|
AudioCache, |
|
|
RateLimiter, |
|
|
VoiceCircuitBreaker, |
|
|
VoiceClient, |
|
|
) |
|
|
|
|
|
__all__ = [ |
|
|
|
|
|
"VoiceIntegrationError", |
|
|
"VoiceAPIError", |
|
|
"VoiceRateLimitError", |
|
|
"VoiceQuotaExhaustedError", |
|
|
"VoiceAuthenticationError", |
|
|
"VoiceUnavailableError", |
|
|
"VoiceCircuitBreakerOpenError", |
|
|
"VoiceNotFoundError", |
|
|
"VoiceSynthesisError", |
|
|
"VoiceConfigurationError", |
|
|
|
|
|
"VoiceType", |
|
|
"VoiceCircuitState", |
|
|
"VoiceServiceState", |
|
|
"VoiceModelType", |
|
|
|
|
|
"VoiceSynthesisSettings", |
|
|
"VoiceProfile", |
|
|
|
|
|
"SynthesisRequest", |
|
|
"SynthesisResult", |
|
|
"TextSegment", |
|
|
"ProcessedNarration", |
|
|
"NarrationResult", |
|
|
|
|
|
"VoiceServiceStatus", |
|
|
|
|
|
"VOICE_PROFILES", |
|
|
"get_voice_profile", |
|
|
"get_voice_profile_by_name", |
|
|
"get_voice_id", |
|
|
"get_voice_settings", |
|
|
"get_all_profiles", |
|
|
"reset_profiles_cache", |
|
|
"select_voice_for_context", |
|
|
"select_voice_from_npc_data", |
|
|
"select_voice_from_game_context", |
|
|
|
|
|
"NarrationProcessor", |
|
|
|
|
|
"VoiceClient", |
|
|
"VoiceCircuitBreaker", |
|
|
"RateLimiter", |
|
|
"AudioCache", |
|
|
] |
|
|
|