Files
stimmwerk/docs/superpowers/specs/2026-11-01-song-analysis-v2-design.md
wlkns-dev 914f9ecfef
All checks were successful
song-analysis-contract / python-contract (push) Successful in 46s
CI / rust (pull_request) Successful in 2m41s
song-analysis-contract / python-contract (pull_request) Successful in 5s
feat: version song analysis contract and preserve lyric lines
2026-11-01 11:24:21 +01:00

10 lines
1.6 KiB
Markdown

# Song Analysis v2 Design
The Python tool keeps raw chord times and `N` spans. Display consumers may snap boundaries to beats and flag spans shorter than 0.5 s; stored times remain unchanged. Chordino's `simplechord` output has no calibrated confidence, so `conf` remains null.
New runs write schema v2. The Rust loader accepts v1 and v2. V2 adds `meta.bpm_source` (`automatic` or `manual`), `meta.source_offset_s` (0), and optional `lyrics.lines[].source_line`, `section`, and `alignment_conf`. With supplied lyrics, input lines and section headings are preserved. WhisperX first transcribes the song to obtain timed phrases, then aligns each supplied line in its own matched phrase window. If matching fails, the line stays unaligned rather than receiving invented timing. A line confidence is the mean of aligned word scores; absent scores yield null. Without supplied lyrics, the output remains a draft with `verified=false`.
`--title` sets the title explicitly. BPM follows `beats.json` unless marked manual, including on reruns. Existing v1 folders remain readable and are not silently rewritten unless a new run writes metadata. The ffmpeg normalization keeps the input timeline origin, so `source_offset_s=0.0`. This does not compensate for encoder delay already present in the decoded source.
Tests cover metadata refresh, v1/v2 loading, lyric structure and windowing. Lightweight CI installs only jsonschema. The optional backend smoke test runs on generated audio in the full environment. CPU timing and observed peak memory are documented as measurements of the one 216 s run, not general guarantees.