- 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.
72 lines
2.7 KiB
Python
72 lines
2.7 KiB
Python
"""Central configuration. One file, one place to change things — see README."""
|
|
import os
|
|
from dataclasses import dataclass, field
|
|
|
|
REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
DEFAULT_CACHE_DIR = os.path.join(REPO_ROOT, "cache")
|
|
REFERENCES_DIR = os.path.join(REPO_ROOT, "references")
|
|
|
|
# The only entry point this tool ever fetches audio/transcripts/subtitles
|
|
# from. Never hardcode the backend it happens to redirect to today (it has
|
|
# been seen redirecting to a DigitalOcean Spaces bucket, but that is an
|
|
# implementation detail of HPR's current hosting, not a stable contract).
|
|
CCDN_BASE = "https://hub.hackerpublicradio.org/ccdn.php"
|
|
|
|
# Canonical metadata dump. Same URL hpr_generator's own download_hpr_sql
|
|
# pulls from.
|
|
HPR_SQL_URL = "https://www.hackerpublicradio.org/hpr.sql"
|
|
|
|
# Minimum gap between requests to HPR's servers. Anyone running this who
|
|
# already understands HPR's infrastructure can lower it; the default has
|
|
# to assume a future user who doesn't, and a `sweep` over the full archive
|
|
# makes several requests per episode across thousands of episodes, so this
|
|
# is a real, not hypothetical, consideration.
|
|
REQUEST_DELAY_SECONDS = 0.5
|
|
|
|
# Try formats in this order; fall back to the next on failure. All three are
|
|
# always published per-episode.
|
|
AUDIO_FORMAT_PREFERENCE = ("opus", "ogg", "mp3")
|
|
|
|
# What HPR's own janitor tooling (hpr-get-and-transcribe.bash) runs. Matched
|
|
# here for consistency with tooling already in people's workflows, not
|
|
# picked as a "lighter" alternative.
|
|
ASR_ENGINE = "openai-whisper"
|
|
ASR_MODEL = "tiny"
|
|
ASR_DEVICE = "cpu"
|
|
|
|
# How much of an episode's head/tail we ever transcribe locally. Detection
|
|
# never needs the whole file.
|
|
HEAD_CLIP_SECONDS = 120
|
|
TAIL_CLIP_SECONDS = 70
|
|
|
|
# Cross-correlation window size for both the reference-asset check and the
|
|
# neighbour-episode fallback.
|
|
XCORR_SAMPLE_RATE = 8000
|
|
XCORR_WINDOW_SECONDS = 0.25
|
|
XCORR_MATCH_THRESHOLD = 0.9
|
|
|
|
# Marker-phrase library version. Bump this whenever markers.json changes;
|
|
# the ledger uses it to know when a cached "no signal found" result needs
|
|
# re-checking against a newer marker set.
|
|
MARKERS_VERSION = 3
|
|
|
|
# Licenses that forbid producing/redistributing a derivative without extra
|
|
# permission. Trimming is refused for these unless explicitly overridden.
|
|
NO_DERIVATIVES_LICENSES = ("CC-BY-ND", "CC-BY-NC-ND")
|
|
|
|
|
|
@dataclass
|
|
class Settings:
|
|
cache_dir: str = DEFAULT_CACHE_DIR
|
|
audio_format_preference: tuple = AUDIO_FORMAT_PREFERENCE
|
|
asr_engine: str = ASR_ENGINE
|
|
asr_model: str = ASR_MODEL
|
|
asr_device: str = ASR_DEVICE
|
|
head_clip_seconds: int = HEAD_CLIP_SECONDS
|
|
tail_clip_seconds: int = TAIL_CLIP_SECONDS
|
|
allow_no_derivatives: bool = False
|
|
|
|
|
|
def default_settings() -> Settings:
|
|
return Settings()
|