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.
This commit is contained in:
Lee Hanken committed 2026-11-22 15:24:54 +00:00
1 parent 5b2426e5ad
commit 815ac0b1df
3 files changed
+123 -20

No files matched your search

+25 -12
View File
@@ -660,18 +660,31 @@ history and `tests/`, not duplicated here:
content](images/pre2015_jingle_envelope_match.png)
(2) is why chroma-feature DTW matching (`audio.dtw_chroma_match`) was
added as a last-resort fallback inside `_sibling_fallback`, tried only
when fixed-lag correlation finds nothing: DTW doesn't assume one global
alignment, so it isn't defeated by internal tempo drift, and its
warping-path end position gives a real intro_end estimate for the
candidate, not just a yes/no. Calibrated on real episodes: confirmed/
likely matches (hpr0908, hpr1117, hpr1467, hpr0901, hpr0902) scored
normalized cost 0.09-0.17 against the reference; a confirmed non-match
(hpr0898, no intro at all) scored 0.94 —
`config.DTW_MATCH_THRESHOLD` (0.35) sits generously between the two.
This is the thing a plain chroma *classifier* (below) can't do: it's
matching against a *specific* reference clip, not asking "does this
sound musical in general."
added: DTW doesn't assume one global alignment, so it isn't defeated by
internal tempo drift, and its warping-path end position gives a real
intro_end estimate for the candidate, not just a yes/no. Calibrated on
real episodes: confirmed/likely matches (hpr0908, hpr1117, hpr1467,
hpr0901, hpr0902) scored normalized cost 0.09-0.17 against the
reference; a confirmed non-match (hpr0898, no intro at all) scored
0.94 — `config.DTW_MATCH_THRESHOLD` (0.35) sits generously between the
two. This is the thing a plain chroma *classifier* (below) can't do:
it's matching against a *specific* reference clip, not asking "does
this sound musical in general."
`detect._check_pre2015_variants` is the main-line check against every
vendored variant (fast correlation first, DTW as the per-variant
fallback), tried for *every* pre-2015 episode before falling back to
neighbour-matching — not confined to `_sibling_fallback`'s small ±2
neighbour radius. This matters more than it might first appear: the
pre-2015 episodes are this tool's core use case, not an edge case —
they're the ones most likely to have no official SRT and no other
usable signal, so the detection needs to work for any one of them, not
just ones lucky enough to have a same-variant neighbour nearby.
Confirmed directly: hpr0908, hpr1117, and hpr1467 are nowhere near
hpr0900 or each other, so they'd never have been found through
`_sibling_fallback`'s radius at all — only through this direct check.
(`_sibling_fallback`'s own DTW fallback still exists underneath, for
whatever jingle variants aren't vendored yet.)
Only one variant is vendored so far; a random 40-episode sample found
it in ~5% of episodes (hpr0900, hpr0908, hpr1117, hpr1467), spread