Add politeness delay between requests, fix two more marker gaps found by smoke-testing
- config.py/fetch.py: enforce a minimum gap between any requests to HPR's
servers (fetch._wait_for_politeness_gap()), regardless of which
function issues them. Not needed for someone who already understands
HPR's infrastructure, but a real consideration for a future user who
doesn't -- a sweep makes several requests per episode across thousands
of episodes.
- markers.json (version 3): found via the same random-sample-then-
visualize technique used for the earlier hpr4775 fix. hpr2157's era
apparently used the bare 'HPR episode' rather than 'Hacker Public Radio
episode', which fell all the way through to a much weaker sibling-
correlation fallback (3.25s) instead of a proper marker match (now
15.1s); Whisper tiny mis-hearing 'Today's' as 'To its' on hpr3356 broke
the same marker a different way (8.0s -> 26.6s). hpr3356 itself is an
unusual 282-minute special episode that remains correctly flagged for
manual review even after the fix.
- docs/DESIGN.md: corrected an overstated claim ('retry with backoff')
that was never actually implemented; documented the real smoke test
(SIGINT mid-episode, resumed, interrupted again, resumed to
completion -- no lost work, no stray subprocesses, no ledger
corruption) and a real full-corpus timing estimate (32.1s/episode
average on the hardest episode category, so on the order of 1-2 days
for the full archive, not weeks).
- New regression tests for the politeness delay and both marker fixes.
This commit is contained in:
1 parent
9917320640
commit
2bef06d108
6 files changed
+145
-26
No files matched your search
+53
-23
@@ -161,8 +161,15 @@ special-cased per status code.
|
||||
a *private* origin-to-mirror-node design: volunteer-run edge nodes `rsync`
|
||||
over SSH from a private origin, not open to the public, with directory
|
||||
browsing explicitly disabled. The practical approach is a polite,
|
||||
resumable, per-episode HTTP fetch loop (skip-if-cached, rate-limited,
|
||||
retry with backoff) — not an attempt to find or build a bulk-sync path.
|
||||
resumable, per-episode HTTP fetch loop — not an attempt to find or build a
|
||||
bulk-sync path. Concretely: every request to HPR's servers goes through a
|
||||
single gate (`fetch._wait_for_politeness_gap()`) enforcing a minimum
|
||||
`config.REQUEST_DELAY_SECONDS` (default 0.5s) between requests, regardless
|
||||
of which function issued them, and `fetch_audio`/`fetch_official_srt`
|
||||
skip the network entirely once a file is cached. Retry-with-backoff on a
|
||||
transient failure is not implemented — a failed request is currently
|
||||
treated the same as "not available," falling through to the next
|
||||
detection signal rather than being retried.
|
||||
|
||||
**Official transcripts/SRT exist, but coverage is patchy — confirmed by
|
||||
direct testing, not assumed.** Even episodes from 2024–2025 sometimes
|
||||
@@ -334,30 +341,30 @@ expected to keep growing.
|
||||
hpr-intro-stripper/
|
||||
├── README.md # minimal: usage, requirements, brief how-it-works
|
||||
├── docs/
|
||||
│ └── DESIGN.md # this file
|
||||
├── references/ # vendored from HPR's own hpr-tools repo (CC0/CC-BY-SA, not this repo's code license)
|
||||
│ └── DESIGN.md # this file
|
||||
├── references/ # vendored from HPR's own hpr-tools repo (CC0/CC-BY-SA, not this repo's code license)
|
||||
│ ├── theme.flac
|
||||
│ ├── outro.flac
|
||||
│ ├── intro.srt
|
||||
│ ├── outro.srt
|
||||
│ ├── mysql2sqlite # the same AWK converter HPR's own tooling uses
|
||||
│ ├── mysql2sqlite # the same AWK converter HPR's own tooling uses
|
||||
│ └── LICENSE_NOTICE.md
|
||||
├── hpr_stripper/
|
||||
│ ├── config.py # the one place to change defaults
|
||||
│ ├── markers.json # versioned, plain-text boilerplate phrase library
|
||||
│ ├── markers.py # fuzzy matching against markers.json
|
||||
│ ├── metadata.py # canonical hpr.sql fetch + sqlite conversion + queries
|
||||
│ ├── fetch.py # audio/transcript/SRT fetch via ccdn.php only
|
||||
│ ├── srt.py # minimal SRT parser (stdlib only)
|
||||
│ ├── audio.py # ffmpeg/ffprobe wrappers, cross-correlation
|
||||
│ ├── asr.py # pluggable ASR backend dispatch
|
||||
│ ├── detect.py # the layered detection pipeline
|
||||
│ ├── ledger.py # resumable per-episode progress tracking
|
||||
│ ├── trim.py # atomic trim + license gating + sidecar metadata
|
||||
│ └── cli.py # detect / sweep / random-sample / trim / report
|
||||
│ ├── config.py # the one place to change defaults
|
||||
│ ├── markers.json # versioned, plain-text boilerplate phrase library
|
||||
│ ├── markers.py # fuzzy matching against markers.json
|
||||
│ ├── metadata.py # canonical hpr.sql fetch + sqlite conversion + queries
|
||||
│ ├── fetch.py # audio/transcript/SRT fetch via ccdn.php only
|
||||
│ ├── srt.py # minimal SRT parser (stdlib only)
|
||||
│ ├── audio.py # ffmpeg/ffprobe wrappers, cross-correlation
|
||||
│ ├── asr.py # pluggable ASR backend dispatch
|
||||
│ ├── detect.py # the layered detection pipeline
|
||||
│ ├── ledger.py # resumable per-episode progress tracking
|
||||
│ ├── trim.py # atomic trim + license gating + sidecar metadata
|
||||
│ └── cli.py # detect / sweep / random-sample / trim / report
|
||||
├── tools/
|
||||
│ └── visualize_clip.sh # renders a waveform/spectrogram for a clip, for inspecting a cut point directly
|
||||
└── cache/ # gitignored: hpr.db, downloaded audio, transcripts, ledger.db, trimmed output
|
||||
│ └── visualize_clip.sh # renders a waveform/spectrogram for a clip, for inspecting a cut point directly
|
||||
└── cache/ # gitignored: hpr.db, downloaded audio, transcripts, ledger.db, trimmed output
|
||||
```
|
||||
|
||||
**What lives in git:** code, the marker-phrase library, the vendored
|
||||
@@ -381,9 +388,20 @@ Two first-class test modes, not ad hoc spot checks:
|
||||
~2020+) so a lucky or unlucky sample can't hide an era-specific
|
||||
regression. Fast, for day-to-day development checks.
|
||||
- **Full-corpus sweep test** (`cli.py sweep`): runs detection (not
|
||||
trimming) across every episode in the archive. Slow — potentially hours
|
||||
once ASR fallback is needed for a meaningful fraction of 4,500+ episodes
|
||||
— and explicitly designed to be interrupted.
|
||||
trimming) across every episode in the archive. Slow — a real,
|
||||
continuous run of 21 episodes from the hardest category (pre-2015, no
|
||||
official transcript, full ASR + sibling-correlation fallback) averaged
|
||||
32.1 seconds/episode on the hardware this was developed on; scaled to
|
||||
the full ~4,750-episode archive that's on the order of a day or two of
|
||||
continuous wall-clock time, not weeks, though a weaker CPU or the
|
||||
politeness delay (see "Data acquisition") would push it higher — and
|
||||
explicitly designed to be interrupted.
|
||||
- **Interrupt/resume was smoke-tested for real, not just unit-tested**:
|
||||
a `sweep` was started, sent a real `SIGINT` mid-episode, resumed (and
|
||||
confirmed it skipped the already-completed episodes rather than
|
||||
reprocessing them), interrupted again, and resumed to completion. No
|
||||
lost work, no stray subprocesses left running after either interrupt,
|
||||
no corrupted ledger state.
|
||||
|
||||
**Resumability is a hard requirement**, because a half-hour-plus batch run
|
||||
*will* get interrupted (Ctrl+C, laptop sleep, SSH drop):
|
||||
@@ -478,7 +496,19 @@ from the generation code itself, not inferred:
|
||||
set didn't recognize yet, so matching stopped two segments early. Fixed
|
||||
in `markers.json` (bumped to version 2); see `tests/test_markers.py`'s
|
||||
`test_2026_wording_variant_is_recognized` for the locked-in regression
|
||||
test.
|
||||
test. The same technique (a `random-sample` run flagging a
|
||||
`metadata_arithmetic` disagreement, then rendering the clip to check
|
||||
which side was actually right) found two more gaps in one pass:
|
||||
hpr2157's era apparently used the bare abbreviation "HPR episode" rather
|
||||
than "Hacker Public Radio episode" (intro_end was landing at 3.25s via
|
||||
the much weaker sibling-correlation fallback, instead of a proper
|
||||
marker match), and Whisper `tiny` mis-hearing "Today's" as "To its" on
|
||||
hpr3356 broke the same marker a different way. Both fixed in
|
||||
`markers.json` (version 3). hpr3356 itself (a 282-minute New Year's Eve
|
||||
marathon episode) remains an open case even after the fix — its
|
||||
structure doesn't cleanly match the standard template, and it's still
|
||||
correctly flagged for manual review rather than given a confident wrong
|
||||
answer.
|
||||
- **The theme-correlation fallback can't bridge a genuine silence gap** —
|
||||
also found via the hpr4775 waveform inspection above, and still open.
|
||||
`generate_intro()` mixes TTS speech additively onto `theme.flac`
|
||||
|
||||
Reference in new issue
Block a user