Commit Graph
2 Commits
Author SHA1 Message Date
Lee Hanken 815ac0b1df Wire the pre-2015 jingle reference into the main detection path
Previously the vendored references/pre2015_jingle_variant_b.flac only
helped via _sibling_fallback's own DTW fallback, which is scoped to a
narrow +/-2 neighbour radius -- confirmed matches like hpr0908, hpr1117,
and hpr1467 are nowhere near hpr0900 or each other, so they'd never have
been found that way.

Adds detect._check_pre2015_variants: checks every vendored pre-2015
jingle variant directly against the episode being detected (fast
correlation first, DTW chroma matching as the per-variant fallback),
tried before falling back to neighbour-matching. This is the pre-2015
era's main-line reference check now, not just a neighbour-radius
fallback -- the old episodes are this tool's core use case, not an edge
case, and the ones most likely to have no official SRT and no other
usable signal.

Verified directly against real episodes outside any neighbour
relationship: hpr0908/hpr1117/hpr1467 resolve via fast correlation,
hpr0901/hpr0902 (tempo-drifted) via DTW, hpr0898 (confirmed no intro)
correctly finds nothing. hpr0899, previously assumed a non-match from
the old buggy correlation-only approach, now also resolves as a real
match -- consistent with that earlier label having been wrong.
2026-11-22 15:24:54 +00:00
Lee Hanken 5b2426e5ad Add DTW-based chroma matching as a fallback for tempo-drifted jingle matches
Fixed-lag cross-correlation (even after the leading_anchor_windows fix)
cannot find every real match: hpr0901 and hpr0902 share hpr0900's
confirmed jingle (by ear, and by a matching ~34s intro-envelope duration
across all three) but never correlate above ~0.3-0.4 against it at any
single fixed lag or speed ratio, because the jingle has internal tempo
variation no global alignment can follow.

Adds audio.dtw_chroma_match: chroma-feature DTW against a reference
clip, which isn't defeated by that since it doesn't assume one global
alignment, and whose warping-path end position gives a real intro_end
estimate. Optional dependency (librosa), same philosophy as ASR -- a
missing import returns None, never an exception. Wired into
detect._sibling_fallback as a last resort, tried only when fixed-lag
correlation finds nothing, since it's far more expensive.

Calibrated on real episodes against the newly vendored
references/pre2015_jingle_variant_b.flac (hpr0900's jingle, confirmed
to recur in ~5% of a random sample): confirmed/likely matches scored
cost 0.09-0.17, a confirmed non-match (hpr0898, no intro at all) scored
0.94. Also tried and rejected for this purpose: generic chroma
classification (can't tell whose music it is, not just that it's music)
and chromaprint/pyacoustid fingerprinting (clean separation but no
tolerance for tempo drift). See docs/DESIGN.md for the full writeup,
including a screenshot showing the matching intro-envelope duration
that motivated this.
2026-11-22 15:21:52 +00:00