Align generated chapters to the played audio timeline via fingerprint timing#4666
Draft
SergioEstevao wants to merge 3 commits into
Draft
Align generated chapters to the played audio timeline via fingerprint timing#4666SergioEstevao wants to merge 3 commits into
SergioEstevao wants to merge 3 commits into
Conversation
… timing Generated chapters are timed against the reference (clean) audio the transcript was generated from, so when a played file has dynamic ads the chapter markers drift out of sync with what's actually playing. When an episode has generated transcripts and generated chapters, re-map each generated chapter's start time from the reference timeline onto the played file's timeline using FingerprintTimingManager, recomputing chapter durations from the adjusted start times. The fingerprint mapping is built asynchronously and grows during playback, so chapters are re-aligned both at parse time and whenever the mapping advances (via a new fingerprintTimingMappingUpdated notification). ChapterManager compiles into targets that don't include the Fingerprint sources (Watch, App Clip, TV), so the dependency is decoupled behind the ChapterReferenceTimeMapping protocol and a provider registry that stays unset (no-op) in those targets. FingerprintTimingManager conforms to the protocol and registers itself in the main app. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collaborator
Generated by 🚫 Danger |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Generated chapters are timed against the reference (clean) audio the transcript was generated from. When the played file contains dynamic ads, the real audio positions shift, so the generated chapter markers drift out of sync with what's actually playing.
This PR re-maps each generated chapter's start time from the reference timeline onto the played file's timeline using
FingerprintTimingManager(the same mapping already used for synced-transcript seeking), and recomputes chapter durations from the adjusted start times.Because the fingerprint mapping is built asynchronously and grows around the current playback position during playback, chapters are re-aligned both at parse time and again whenever the mapping advances — via a new
fingerprintTimingMappingUpdatednotification. Chapters ahead of the covered region keep their reference times until coverage reaches them, then self-correct.Notes for reviewers
ChapterManagercompiles into targets that do not include theFingerprintsources (Watch, App Clip, TV). To avoid breaking those builds, the dependency is decoupled behind theChapterReferenceTimeMappingprotocol + aChapterReferenceTimeMappingProviderregistry. The provider stays unset in those targets, so the adjustment is a no-op there and generated chapters simply keep their reference times.FingerprintTimingManagerconforms to the protocol (hasChapterReferenceMappingis true once.active, and the existingplaybackTime(forReferenceTime:)satisfies the mapping requirement) and registers itself as the provider in the main app.chaptersOrigin == .generatedand an active mapping. The active-mapping requirement implicitly covers "has generated transcripts", since the fingerprint reference only exists for generated-transcript episodes.To test
.active, confirm the chapter markers/boundaries line up with the real audio content rather than being offset by the inserted ads.Checklist
CHANGELOG.mdif necessary.