the ultimate vocal synthesizer - sing, speak, beatbox, and more
Rust
Hill climb batch 2: Whisper decides, 20 held-out sentences, the singer guards
Jameson Hodge1c7c60080612
diff --git a/docs/hill-climb/README.md b/docs/hill-climb/README.mdindex 008beee..8b5c452 100644--- a/docs/hill-climb/README.md+++ b/docs/hill-climb/README.md@@ -8,10 +8,37 @@ until the owner has listened to the result and merged it.The log of every experiment is [log.md](log.md). Read it before you start.+## The current batch: pronunciation (batch 2)++Batch 1 tuned the singing toward the singer. The owner heard the gain, but found it incremental and+cared more about pronunciation. So batch 2 swaps the roles of the judges:++- **Speech decides.** A change is kept only if the speech verdict (Whisper's word error rate on the+ training sentences) is **BETTER**: at least 1.5 points lower than the best run.+- **The singer guards.** Against the batch's baseline, no singer guard may break (notes off time,+ dropped gestures, note MCD, envelope correlation, pitch), and the training score may rise by+ at most **0.05**. Singing is what batch 1 earned; don't spend it.+- **Targets**, from what the owner heard (details in log.md, "Listening result"):+ 1. sh, ch and j are too quiet and too low: "sheet" is heard as "feet", and j sounds muted.+ Every ch and j word in the training sentences fails.+ 2. Stressed vowels are squeezed: the "pu" of "pushes" lasts about 40 ms.+ 3. The p of "sharp" pops. Between the closed lips and the tongue sealing for the following /t/,+ the tongue squeezes the shut-in air to 11x the lungs' pressure, and the /p/ releases 7 dB+ above the sentence's loudest vowel (male; the p's of "paper" sit at −6 and −7 dB). Measure+ it with `cargo test --release -p chimera --test consonant_artifacts -- --ignored+ --nocapture`; the batch PR un-ignores that test once it passes. Simply absorbing a sealed+ pocket's wall motion was tried: it halves the pop but breaks the adiabatic-compression test+ in `airway_adversarial.rs` and the creatures' parity. Look at the articulation instead (how+ far and how late the tongue moves with the lips shut), or at a real leak path. Male p+ releases are loud in general (about −5 dB in "apa"; female −13 dB).+ 4. Anything else Whisper's errors point at: the training sentences' wrong words are listed by+ the speech judge.+- **Branch:** `t3/pronunciation-hill-climb`, stacked on `t3/consonant-fixes` (the fix for the+ buzz, and the Bright control).+## Before you start-- **Where.** Work in this worktree, on branch `t3/vocal-quality-hill-climb`. Never commit to- main.+- **Where.** Work in this worktree, on the batch's branch (above). Never commit to main.- **Data.** The dataset is in `~/datasets/csd/CSD` (fetch it with `tools/fetch-csd.sh`). Thespeech judge needs `tools/asr/setup.sh` once.- **The best run so far** is in `out/hill/best/`: `score.json` and `report.md` (singer),@@ -24,12 +51,14 @@ The log of every experiment is [log.md](log.md). Read it before you start.## One experiment-1. **Pick one hypothesis.** Read `out/hill/best/report.md` (the score table, largest costs- first) and the log. Aim at a large cost the log doesn't show as exhausted, or try a new angle- on one. Before you touch code, write down in a sentence or two:+1. **Pick one hypothesis.** Read the log and the deciding judge's output: for batch 2, the+ sentences Whisper got wrong in `out/hill/best/speech/wer.json` and the targets above (for a+ singing batch, `out/hill/best/report.md`, largest costs first). Aim at something the log+ doesn't show as exhausted, or try a new angle on it. Before you touch code, write down in a+ sentence or two:- what is physically wrong- what you will change- - which terms should move+ - which words or terms should move2. **Make the change.** Keep it small, readable and motivated by physiology, acoustics orphonetics. These are fair game:- the voice source (`crates/chimera/src/sources/`)@@ -49,6 +78,7 @@ The log of every experiment is [log.md](log.md). Read it before you start.- `crates/chimera-cli/src/compare.rs`, `compare/score.rs`- `tools/asr/`- the held-out songs, the dataset, the sentences+ - `crates/chimera/tests/consonant_artifacts.rs`The comparison sings with the settings `render song` uses: pressure 9, tension 0.55 and35-cent vibrato (`render_notes` in compare.rs). Change how the engine responds to those@@ -65,22 +95,27 @@ The log of every experiment is [log.md](log.md). Read it before you start.the log.- **The tests.** Don't weaken or delete one to let a change through. A failing test, other thana golden fixture (below), means the change is reverted.-- **The held-out songs as a guide.** Decide on the training verdict only, and don't choose- changes by the held-out score. It is there to show whether a gain carries over.+- **The held-out songs and sentences as a guide.** Decide on the training verdict only, and+ don't choose changes by the held-out scores or read the held-out sentences' transcripts. They+ are there to show whether a gain carries over.## Measuring```shcargo build --release -p chimera-cli-cargo run --release -p chimera-cli -- compare csd ~/datasets/csd/CSD out/hill/try --against out/hill/best/score.json-~/.cache/chimera-asr/.venv/bin/python tools/asr/speech_wer.py out/hill/try/speech --against out/hill/baseline/speech/wer.json+cargo run --release -p chimera-cli -- compare csd ~/datasets/csd/CSD out/hill/try --against out/hill/baseline/score.json+~/.cache/chimera-asr/.venv/bin/python tools/asr/speech_wer.py out/hill/try/speech --against out/hill/best/speech/wer.jsoncargo run --release -q -p chimera --example bench > out/hill/try/bench.txt```+These are batch 2's comparisons: speech against the best run (it decides), the singer against the+batch's baseline (it guards). A singing batch swaps the two `--against` files.+1. **Singer.** The comparison ends with a verdict: BETTER, WORSE or NO CLEAR CHANGE, and thereasons when worse. `out/hill/try/report.md` has the new score table.-2. **Speech.** The speech judge ends with OK or WORSE. WORSE means the word error rate is more- than 3 points above the batch's baseline. It also lists the sentences Whisper got wrong.+2. **Speech.** The speech judge ends with BETTER, WORSE or NO CLEAR CHANGE on the training+ sentences: BETTER from 1.5 points lower, WORSE past 3 points higher. It lists the sentences+ Whisper got wrong, and reports the held-out sentences, which never decide.3. **Speed.** The bench prints the real-time load. Compare its `os=2` line with`out/hill/baseline/bench.txt`, the batch's baseline. It is noisy and depends on what elsethe machine is doing, so if it reads slower, rerun it and the baseline's commit back to@@ -88,10 +123,12 @@ cargo run --release -q -p chimera --example bench > out/hill/try/bench.txt## Keep or revert-Keep the change only if all of these hold:+Keep the change only if all of these hold (batch 2; a singing batch swaps 1 and 2 back, with+speech judged against the batch's baseline and required to be not WORSE):-1. The singer verdict is **BETTER**.-2. The speech verdict is **OK**.+1. The speech verdict is **BETTER**.+2. Against the batch's baseline, the singer breaks no guard and its training score rises by at+ most 0.05.3. The bench is no more than **10 % slower** than the batch's baseline.4. **The tests pass.**1. Bless the golden fixtures in `crates/chimera/tests/golden`. They are snapshots of the@@ -117,10 +154,9 @@ Keep the change only if all of these hold:1. Commit the engine change (without the fixtures). The message gives the hypothesis, thechange, and the numbers:- - training score before → after- - held-out score before → after- - speech word error rate before → after- - the terms that moved+ - speech word error rate before → after, training and held-out+ - training and held-out singer score before → after+ - the words or terms that moved2. Replace `out/hill/best` with `out/hill/try`:`rm -rf out/hill/best && mv out/hill/try out/hill/best`.3. Add the log entry, commit it, and push.@@ -140,8 +176,8 @@ Add one entry at the end of `log.md`:- Hypothesis: what was wrong and why the change should fix it.- Change: what changed, in which files; values tried.+- Speech: word error rate a → b (training), c → d (held-out); the words that moved.- Singer: training score a → b, held-out c → d; the terms that moved.-- Speech: word error rate a → b.- Verdict: the reasons, if reverted.- Commit: the hash, if kept.- Next: what this suggests trying, or not trying, next.diff --git a/docs/hill-climb/log.md b/docs/hill-climb/log.mdindex 110c512..6dbc136 100644--- a/docs/hill-climb/log.md+++ b/docs/hill-climb/log.md@@ -511,3 +511,39 @@ Whisper agrees with the user on the word errors (sheet → feet, and the j and csupports using it as the pronunciation judge. It disagrees on one: it heard "pushes" correctly inthe female voice after the batch (before it heard "puffs"). It can't judge the pop or the buzz,since neither changes the words, so those need checks of their own.++## Batch 2: pronunciation (from 2026-11-07)++Batch 1 is merged (PR #16). The owner's listening (above) asked for pronunciation, so batch 2's+judge is Whisper. See the README's "current batch" section for the rules.++### Before the batch: the fixes and the Bright control (PR #19, not a hill-climb step)++- **The tinny ring: fixed.** It was a 750 Hz buzz from the lung pressure stepping once per+ control block. It now ramps across the block. Block-periodic share of a word's tail ~20 % →+ under 1 %.+- **The pop on "sharp": not fixed.** The tongue squeezes the air between the closed lips and its+ /t/ seal to 11x the lungs' pressure (88 cmH2O). The /p/ releases at +7 dB re the sentence's+ loudest vowel (male). Absorbing a sealed pocket's wall motion halved it but broke the engine's+ adiabatic-compression test and the creatures' parity; reverted. The ignored test+ `the_p_of_sharp_does_not_pop` in `tests/consonant_artifacts.rs` measures it.+- **Bright control** (`VoiceSource.brightness`, default 0.25 = the current sound).+- Against batch 1's best: singer 0.623 → 0.582 (BETTER, onsets), held-out 0.791 → 0.789; speech+ 39.4 → 40.7 %; speed 18.2 % of one core.++### The judge for batch 2++- `tools/asr/sentences.tsv` gained 20 held-out sentences (set column "held"): Harvard list 2, and+ ten unpredictable sentences dense in sh, ch and j. They never decide.+- `speech_wer.py --against` now says BETTER (training word error rate down by at least 1.5+ points), WORSE (up by more than 3) or NO CLEAR CHANGE, and reports the held-out rate.+- The old batch-1 directories are kept as `out/hill/batch1-baseline` and `out/hill/batch1-best`.++### Batch 2 baseline (commit 4980e3b, `out/hill/baseline`)++- Speech, training: **40.73 %** (harvard female 37.5, male 37.5; nonsense female 42.25, male+ 46.48). Held-out: **50.67 %** (harvard female 35.44, male 39.24; nonsense female 70.42, male+ 60.56).+- Singer: training 0.582, held-out 0.789.+- Speed: 18.2 % of one core (`os=2`).+- The /p/ of "sharp": +7.0 dB re the loudest vowel, oral pressure 11.1x the lungs' (male).diff --git a/tools/asr/sentences.tsv b/tools/asr/sentences.tsvindex 03f1b6b..fa2fa22 100644--- a/tools/asr/sentences.tsv+++ b/tools/asr/sentences.tsv@@ -1,20 +1,40 @@-harvard The birch canoe slid on the smooth planks.-harvard Glue the sheet to the dark blue background.-harvard It's easy to tell the depth of a well.-harvard These days a chicken leg is a rare dish.-harvard Rice is often served in round bowls.-harvard The juice of lemons makes fine punch.-harvard The box was thrown beside the parked truck.-harvard The hogs were fed chopped corn and garbage.-harvard Four hours of steady work faced us.-harvard A large size in stockings is hard to sell.-nonsense The green chair drinks the late song.-nonsense A cold paper walks under the sharp tree.-nonsense The thin road hears a loud milk.-nonsense Some bright doors sell the quiet fish.-nonsense The wet bird pushes a heavy number.-nonsense Her round table sings the dark rope.-nonsense A fast window paints the sweet stone.-nonsense The small river eats the black chain.-nonsense The long fork reads a soft hill.-nonsense One tall cloud fixes the warm bell.+harvard The birch canoe slid on the smooth planks. train+harvard Glue the sheet to the dark blue background. train+harvard It's easy to tell the depth of a well. train+harvard These days a chicken leg is a rare dish. train+harvard Rice is often served in round bowls. train+harvard The juice of lemons makes fine punch. train+harvard The box was thrown beside the parked truck. train+harvard The hogs were fed chopped corn and garbage. train+harvard Four hours of steady work faced us. train+harvard A large size in stockings is hard to sell. train+nonsense The green chair drinks the late song. train+nonsense A cold paper walks under the sharp tree. train+nonsense The thin road hears a loud milk. train+nonsense Some bright doors sell the quiet fish. train+nonsense The wet bird pushes a heavy number. train+nonsense Her round table sings the dark rope. train+nonsense A fast window paints the sweet stone. train+nonsense The small river eats the black chain. train+nonsense The long fork reads a soft hill. train+nonsense One tall cloud fixes the warm bell. train+harvard The boy was there when the sun rose. held+harvard A rod is used to catch pink salmon. held+harvard The source of the huge river is the clear spring. held+harvard Kick the ball straight and follow through. held+harvard Help the woman get back to her feet. held+harvard A pot of tea helps to pass the evening. held+harvard Smoky fires lack flame and heat. held+harvard The soft cushion broke the man's fall. held+harvard The salt breeze came across from the sea. held+harvard The girl at the booth sold fifty bonds. held+nonsense The cheap ship judges the pale shell. held+nonsense A fresh chin pushes the bitter jar. held+nonsense Some shy chairs jump over the cold page. held+nonsense The rich shadow pulls a quick bridge. held+nonsense Her brown sheep catches the shiny cage. held+nonsense A soft church shakes the deep edge. held+nonsense The tall judge washes a purple cherry. held+nonsense One short badge teaches the fast cushion. held+nonsense The plain pitcher shoves a huge sponge. held+nonsense A bright shop chooses the gentle sheet. helddiff --git a/tools/asr/speech_wer.py b/tools/asr/speech_wer.pyindex 2220cae..e5e5029 100644--- a/tools/asr/speech_wer.py+++ b/tools/asr/speech_wer.py@@ -4,12 +4,15 @@usage: speech_wer.py <outdir> [--against earlier/wer.json]-Writes <outdir>/wer.json and the renders. With --against it says whether the word error rate-rose by more than SLACK points, which a tuning loop treats as a speech regression.+Writes <outdir>/wer.json and the renders. With --against it compares the training sentences'+word error rate: BETTER if it fell by at least MARGIN points, WORSE if it rose by more than+SLACK, and NO CLEAR CHANGE between. The held-out sentences are reported but never decide.Set up once with tools/asr/setup.sh (a Python env and the model in ~/.cache/chimera-asr).-The sentences are in sentences.tsv: Harvard sentences (IEEE 1969) and semantically-unpredictable ones, which Whisper can't guess from context.+The sentences are in sentences.tsv (kind, text, set): Harvard sentences (IEEE 1969) and+semantically unpredictable ones, which Whisper can't guess from context. "train" sentences are+the ones a tuning loop may listen to; "held" ones (Harvard list 2, and unpredictable sentences+dense in sh, ch and j) only check that gains carry over."""import json@@ -29,6 +32,8 @@ CACHE = os.path.expanduser("~/.cache/chimera-asr/models")BODIES = ("male", "female")# word error rate (points) a change may add before it counts as a speech regressionSLACK = 3.0+# fall in word error rate (points) that counts as an improvement: about 4 of the ~290 training words+MARGIN = 1.5def words(text):@@ -64,13 +69,13 @@ def main():del args[i : i + 2]out = args[0]os.makedirs(out, exist_ok=True)- sentences = [line.rstrip("\n").split("\t") for line in open(os.path.join(HERE, "sentences.tsv"))]+ sentences = [(line.rstrip("\n").split("\t") + ["train"])[:3] for line in open(os.path.join(HERE, "sentences.tsv"))]chimera = os.path.join(REPO, "target/release/chimera")- jobs = [(kind, text, body, os.path.join(out, f"{kind}-{body}-{i + 1:02d}"))- for i, (kind, text) in enumerate(sentences) for body in BODIES]+ jobs = [(kind, text, body, os.path.join(out, f"{kind}-{body}-{i + 1:02d}"), part)+ for i, (kind, text, part) in enumerate(sentences) for body in BODIES]def render(job):- _, text, body, stem = job+ _, text, body, stem, _ = jobsubprocess.run([chimera, "render", "text", stem, text, body], check=True, capture_output=True)with ThreadPoolExecutor(os.cpu_count()) as pool:@@ -79,14 +84,16 @@ def main():model = WhisperModel("small.en", device="cpu", compute_type="int8", cpu_threads=os.cpu_count(),download_root=CACHE)rows, totals = [], {}- for kind, text, body, stem in jobs:+ for kind, text, body, stem, part in jobs:segs, _ = model.transcribe(load16k(stem + ".wav"), language="en", beam_size=1, temperature=0.0,condition_on_previous_text=False, vad_filter=False)heard = " ".join(s.text.strip() for s in segs)ref = words(text)e = edits(ref, words(heard))- rows.append({"kind": kind, "body": body, "text": text, "heard": heard, "errors": e, "words": len(ref)})- for key in (f"{kind}-{body}", "all"):+ rows.append({"kind": kind, "body": body, "set": part, "text": text, "heard": heard, "errors": e, "words": len(ref)})+ # "all" is the training sentences (as before held-out ones existed); "held" the others+ keys = (f"{kind}-{body}", "all") if part == "train" else (f"held-{kind}-{body}", "held")+ for key in keys:t = totals.setdefault(key, [0, 0])t[0] += et[1] += len(ref)@@ -96,13 +103,15 @@ def main():json.dump(report, f, indent=1)for r in rows:if r["errors"]:- print(f" {r['kind']:8s} {r['body']:6s} {r['errors']}/{r['words']} {r['text']} → {r['heard']}")+ print(f" {r['set']:5s} {r['kind']:8s} {r['body']:6s} {r['errors']}/{r['words']} {r['text']} → {r['heard']}")print("word error rate (%): " + ", ".join(f"{k} {v}" for k, v in sorted(wer.items())))if against:- old = json.load(open(against))["wer"]["all"]- new = wer["all"]- verdict = "WORSE" if new > old + SLACK else "OK"- print(f"speech verdict against {against}: {verdict} (word error rate {old} → {new} %, slack {SLACK})")+ before = json.load(open(against))["wer"]+ old, new = before["all"], wer["all"]+ verdict = "WORSE" if new > old + SLACK else "BETTER" if new <= old - MARGIN else "NO CLEAR CHANGE"+ held = f"; held-out {before['held']} → {wer['held']} %, not used to decide" if "held" in before else ""+ print(f"speech verdict against {against}: {verdict} (training word error rate {old} → {new} %, "+ f"better from -{MARGIN}, worse past +{SLACK}{held})")main()