Overview
TranslationManager handles real-time speech translation functionality within a user session. It provides provider abstraction for multiple translation services (Azure and Soniox), manages translation stream lifecycle independently from transcription, supports multi-language pairs, and implements audio buffering for seamless stream transitions. File:packages/cloud/src/services/session/translation/TranslationManager.ts
Key Features
- Provider Abstraction: Supports Azure and Soniox translation services
- Independent Stream Management: Translation streams separate from transcription
- Multi-Language Pair Support: Handles various source-to-target language combinations
- Audio Buffering: Prevents speech loss during stream startup
- Automatic Provider Failover: Falls back to alternative providers on failure
- Stream Health Monitoring: Detects and replaces unhealthy streams
- VAD-Aware Lifecycle: Preserves subscriptions during VAD silence periods
Architecture
Subscription Management
Subscription Format
Translation subscriptions follow the pattern:translation:{source}-to-{target}
Example: translation:en-to-es (English to Spanish)
Subscription Updates
Stream Lifecycle Management
Stream Creation
VAD-Aware Stream Management
Audio Buffering
Buffer Configuration
Buffer Operations
Provider Management
Provider Initialization
Provider Selection
Stream Health Management
Health Checking
Stream Synchronization
Data Distribution
Translation Data Relay
Audio Feed Integration
Metrics and Monitoring
Configuration
Timing Constants
Lifecycle Management
Disposal
Best Practices
- Always buffer audio during stream startup to prevent speech loss
- Monitor stream health and replace unhealthy streams automatically
- Preserve subscriptions during VAD silence for quick resume
- Validate language pairs to prevent same-language translation
- Use appropriate providers based on language support
- Handle provider failures gracefully with automatic failover
Integration Points
- AudioManager: Receives audio data for translation
- TranscriptionManager: Works in parallel for transcription
- SubscriptionService: Determines which apps receive translations
- Provider Classes: Azure and Soniox implementations
- VAD Detection: Triggers stream lifecycle events
Related Documentation
- AudioManager: Audio source
- TranscriptionManager: Parallel transcription
- SubscriptionService: App subscriptions
- Message Types: Translation data formats