pub struct SyncEngine { /* private fields */ }Expand description
Unified sync engine based on VAD voice detection.
This engine provides automatic subtitle synchronization using Voice Activity Detection (VAD) to analyze audio tracks and calculate optimal sync offsets.
Implementations§
Source§impl SyncEngine
impl SyncEngine
Sourcepub fn new(config: SyncConfig) -> Result<SyncEngine, SubXError>
pub fn new(config: SyncConfig) -> Result<SyncEngine, SubXError>
Create a new sync engine instance.
§Arguments
config- Sync configuration containing VAD settings and thresholds
§Returns
A new sync engine instance with initialized VAD detector if enabled.
The VAD detector requirement is unconditional: construction fails
when config.vad.enabled is false as well as when detector
initialization fails, regardless of the sync method the caller will
ultimately use. A caller that only needs the manual-offset transform
should use crate::core::sync::shift_subtitle_timing instead of
constructing an engine.
Sourcepub fn with_reporter(self, reporter: Arc<dyn Reporter>) -> SyncEngine
pub fn with_reporter(self, reporter: Arc<dyn Reporter>) -> SyncEngine
Attach a reporting sink, consuming and returning the engine.
§Arguments
reporter- Sink reserved for the sync engine’s future progress/cancellation reporting (seeexpose-core-orchestration-apis).
Sourcepub fn reporter(&self) -> &Arc<dyn Reporter> ⓘ
pub fn reporter(&self) -> &Arc<dyn Reporter> ⓘ
The attached reporting sink (used by future progress/cancellation reporting work).
Sourcepub async fn detect_sync_offset(
&self,
audio_path: &Path,
subtitle: &Subtitle,
method: Option<SyncMethod>,
) -> Result<SyncResult, SubXError>
pub async fn detect_sync_offset( &self, audio_path: &Path, subtitle: &Subtitle, method: Option<SyncMethod>, ) -> Result<SyncResult, SubXError>
Sourcepub fn apply_manual_offset(
&self,
subtitle: &mut Subtitle,
offset_seconds: f32,
) -> Result<SyncResult, SubXError>
pub fn apply_manual_offset( &self, subtitle: &mut Subtitle, offset_seconds: f32, ) -> Result<SyncResult, SubXError>
Apply manual offset to subtitle timing.
§Arguments
subtitle- Mutable subtitle data to modifyoffset_seconds- Offset in seconds (positive delays, negative advances)
§Returns
Sync result with the applied offset and full confidence.
§Errors
Returns an error if the offset exceeds the configured maximum.