-
-
Notifications
You must be signed in to change notification settings - Fork 0
Translation Engine
Section: Pipeline · Diarization-and-Speaker-Management · Home · Text-to-Speech
The Translation Engine converts timed text segments from a source language to a target language. It sits between ASR and TTS. Routes include local ONNX-backed models and optional cloud providers. Shipping lanes stay commercial-safe via the model manifest. Domain concepts include translated segments, revisions, and language routing results.
The translation system is designed around a strict layered dependency model where orchestration occurs in the Application layer, while specific implementations reside in Infrastructure (for cloud) or Inference.Onnx (for local).
The translation workflow follows a structured sequence where segments are prepared, routed to a specific engine, and then processed into immutable snapshots.
flowchart TD
Start[Start Translation Stage] --> Prepare[Prepare Translation Request]
Prepare --> Route[IRuntimePlanner Selects Engine]
Route --> Direct[Direct Route: e.g. Opus-MT]
Route --> Pivot[Pivot Route: e.g. MADLAD-400]
Direct --> Execute[Execute TranslateAsync]
Pivot --> Execute
Execute --> Metadata[Report Execution Metadata]
Execute --> Result[Return TranslatedTextSegments]
Result --> End[Update Pipeline Status]
The diagram shows the logic flow from initiating a translation stage to selecting a routing path and executing the engine.
| Component | Responsibility | File Path Reference |
|---|---|---|
ITranslationEngine |
The primary interface for all translation implementations. | src/Trackdub.Infrastructure/Translation/GeminiCloudTranslationEngine.cs |
IRuntimePlanner |
Determines routing (Direct vs. Pivot) and execution provider (CPU, GPU, etc.). | Inference / Composition planner types |
TranslationWorkflow |
Orchestrates the translation stage within the application pipeline. | src/Trackdub.Application/Transcripts/TranslationWorkflow.cs |
GeminiCloudTranslationEngine |
A specific implementation utilizing the Google Gemini Cloud API. | src/Trackdub.Infrastructure/Translation/GeminiCloudTranslationEngine.cs |
Cloud-based engines like GeminiCloudTranslationEngine implement ITranslationEngine along with reporting interfaces to provide telemetry on model usage and bootstrap details.
The following sequence diagram illustrates how a cloud engine interacts with external APIs while maintaining internal state reporting.
sequenceDiagram
participant App as Application Layer
participant Eng as GeminiCloudTranslationEngine
participant API as Gemini API
App->>Eng: TranslateAsync(TranslationRequest)
activate Eng
Eng->>Eng: ResolveApiKeyAsync()
Eng->>API: POST /generateContent (JSON Array)
API-->>Eng: 200 OK (Translated JSON)
Eng->>Eng: TryParseTranslationArray()
Eng->>Eng: Update LastExecutionMetadata
Eng->>Eng: Update LastExecutionSummary
Eng-->>App: IReadOnlyList<TranslatedTextSegment>
deactivate Eng
Interaction between the Application layer and the Gemini Cloud Translation Engine.
The engine uses specific system instructions to ensure the LLM returns only valid JSON arrays without markdown or explanations, preserving the order and count of segments. It also reports TranslationRoutingKind.Direct for supported direct language pairs.
Translation routing is strictly manifest-driven. The system uses a bundled-models.manifest.json to track capabilities and licensing.
- Direct Route: Used for specific language pairs supported by a single model (e.g., Opus-MT).
- Pivot Route: Used when no direct model exists, often routing through a larger multilingual model like MADLAD-400.
-
Commercial Safe Mode: When enabled, the
IRuntimePlannerblocks any route that involves a model marked as non-commercial in the manifest.
Cloud engines require specific environment variables for API keys to function:
-
GEMINI_API_KEYorTRACKDUB_GEMINI_API_KEYfor Gemini. - Cloud providers are accessed via an
ICloudApiKeyProvider.
The translation domain maintains several core types to ensure data integrity across the pipeline:
- TranslatedTextSegment: Contains the translated string mapped to original start and end timestamps.
- TranslationRequest: A container for segments, source language, and target language.
- TranslationExecutionMetadata: Records the provider, model ID, model alias, and routing kind used for a specific run.
The Translation Engine facilitates cross-platform, local-first translation by abstracting provider-specific logic behind the ITranslationEngine interface. By leveraging a manifest-driven IRuntimePlanner, Trackdub ensures that translation requests are handled by the most appropriate model—be it a local ONNX model or a cloud service—while strictly adhering to commercial licensing constraints and preserving segment timing integrity.
Trackdub Engineering Wiki · Trackdub-gated · Trackdub · Contributing
Overview
Architecture
Pipeline
- Pipeline-Orchestration
- Media-Ingest-and-Preparation
- Transcription-and-VAD
- Diarization-and-Speaker-Management
- Translation-Engine
- Text-to-Speech
- Lip-Sync-and-Synthesis
- Mixing-and-Export
Desktop App
AI & Inference
- Inference-Routing-and-Planning
- ONNX-Execution-Providers
- Model-Manifests-and-Governance
- Hardware-Starter-Packs
Media & Audio
Data
Cloud & SaaS
- Cloud-API-and-Job-Management
- Web-Dashboard
- Billing-and-Quota-Management
- Webhook-Delivery-System
- Cloud-Infrastructure-Deployment
Development
Links