Skip to content

the ultimate vocal synthesizer - sing, speak, beatbox, and more

Rust

Batch review fixes: pressed closure back, atomic fixtures, fixed-baseline guards

Jameson Hodgeacc62e30c5fa
diff --git a/crates/chimera/src/voice/human_voice.rs b/crates/chimera/src/voice/human_voice.rs
index 734d0ae..7962ce5 100644
--- a/crates/chimera/src/voice/human_voice.rs
+++ b/crates/chimera/src/voice/human_voice.rs
@@ -303,8 +303,9 @@ impl HumanVoice {
g.open_quotient = 0.78 - 0.36 * s.tension;
// The folds close along their length and depth over a return phase, not all at once, so
// a sung or spoken voice closes softly (0.22 at tension 0.55): an abrupt closure put
- // 3-8 dB too much energy above 2 kHz. A tenser voice still closes more sharply.
- g.closure_sharpness = 0.4 * s.tension;
+ // 3-8 dB too much energy above 2 kHz. Pressing harder than that brings the abrupt closure
+ // back, up to 0.95 at full tension, so a pressed voice still has its edge.
+ g.closure_sharpness = 0.4 * s.tension + 1.375 * js_max(0.0, s.tension - 0.6);
g.skew = 0.56 + 0.16 * s.tension;
g.fry = s.fry;
// Jitter of a healthy, trained voice at the default roughness (0.1): about 0.45 %, well
diff --git a/crates/chimera/tests/common/mod.rs b/crates/chimera/tests/common/mod.rs
index beb96fc..1e86570 100644
--- a/crates/chimera/tests/common/mod.rs
+++ b/crates/chimera/tests/common/mod.rs
@@ -48,17 +48,24 @@ pub fn blessing() -> bool {
std::env::var("CHIMERA_BLESS").is_ok_and(|v| v == "1")
}
+/// Replace a fixture in one step (write a temporary file, then rename it over the old one), so a
+/// test reading it while another blesses it sees the old file or the new, never half of one.
+fn write_fixture(path: &str, bytes: &[u8]) {
+ let tmp = format!("{path}.{}.tmp", std::process::id());
+ std::fs::write(&tmp, bytes).unwrap();
+ std::fs::rename(&tmp, path).unwrap();
+ println!("blessed {path}");
+}
+
pub fn save_f32(name: &str, data: &[f32]) {
let path = format!("{}/tests/golden/{name}.f32", env!("CARGO_MANIFEST_DIR"));
let bytes: Vec<u8> = data.iter().flat_map(|x| x.to_le_bytes()).collect();
- std::fs::write(&path, bytes).unwrap();
- println!("blessed {path}");
+ write_fixture(&path, &bytes);
}
pub fn save_json(name: &str, v: &Value) {
let path = format!("{}/tests/golden/{name}.json", env!("CARGO_MANIFEST_DIR"));
- std::fs::write(&path, serde_json::to_string(v).unwrap()).unwrap();
- println!("blessed {path}");
+ write_fixture(&path, serde_json::to_string(v).unwrap().as_bytes());
}
/// For renders that may legitimately part after a discrete decision goes the other way on a
diff --git a/crates/chimera/tests/voice_source.rs b/crates/chimera/tests/voice_source.rs
new file mode 100644
index 0000000..6260286
--- /dev/null
+++ b/crates/chimera/tests/voice_source.rs
@@ -0,0 +1,22 @@
+//! How the human voice's source settings shape the glottis.
+use chimera::voice::human_voice::{HumanVoice, SourcePatch};
+
+#[test]
+fn a_pressed_voice_still_closes_abruptly() {
+ // a sung or spoken voice closes softly (tension 0.5-0.55), but the "Pressed" control's top end
+ // keeps the abrupt closure of a pressed voice, and the closure sharpens with tension throughout
+ let mut v = HumanVoice::with_defaults(48000.0);
+ let mut sharpness = |tension: f64| {
+ v.set_source(&SourcePatch { tension: Some(tension), ..Default::default() });
+ v.glottis.params.closure_sharpness
+ };
+ assert!(sharpness(0.55) < 0.25);
+ assert!(sharpness(1.0) > 0.9);
+ let mut last = -1.0;
+ for i in 0..=20 {
+ let t = i as f64 / 20.0;
+ let s = sharpness(t);
+ assert!(s > last, "closure sharpness falls at tension {t}");
+ last = s;
+ }
+}
diff --git a/docs/hill-climb/README.md b/docs/hill-climb/README.md
index 5f843ec..008beee 100644
--- a/docs/hill-climb/README.md
+++ b/docs/hill-climb/README.md
@@ -17,6 +17,10 @@ The log of every experiment is [log.md](log.md). Read it before you start.
- **The best run so far** is in `out/hill/best/`: `score.json` and `report.md` (singer),
`speech/wer.json` (speech) and `bench.txt` (speed). If it is missing, measure the current
commit into `out/hill/best` the same way as below.
+- **The batch's baseline** is in `out/hill/baseline/`, measured the same way at the commit the
+ batch started from. Speech and speed are judged against it, not against the best run. A
+ small allowance per step would otherwise add up over a batch. Reset it when a batch is
+ merged and the next one starts.
## One experiment
@@ -69,16 +73,18 @@ The log of every experiment is [log.md](log.md). Read it before you start.
```sh
cargo 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/best/speech/wer.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 -q -p chimera --example bench > out/hill/try/bench.txt
```
1. **Singer.** The comparison ends with a verdict: BETTER, WORSE or NO CLEAR CHANGE, and the
reasons 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 rose by
- more than 3 points. It also lists the sentences Whisper got wrong.
+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.
3. **Speed.** The bench prints the real-time load. Compare its `os=2` line with
- `out/hill/best/bench.txt`. It is noisy, so rerun it once before calling a change slower.
+ `out/hill/baseline/bench.txt`, the batch's baseline. It is noisy and depends on what else
+ the machine is doing, so if it reads slower, rerun it and the baseline's commit back to
+ back before calling a change slower.
## Keep or revert
@@ -86,7 +92,7 @@ Keep the change only if all of these hold:
1. The singer verdict is **BETTER**.
2. The speech verdict is **OK**.
-3. The bench is no more than **10 % slower**.
+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
sound (the `.f32` files) and of the planners' output (the utterance, duration, phrase,
diff --git a/docs/hill-climb/log.md b/docs/hill-climb/log.md
index 695c79d..3c90418 100644
--- a/docs/hill-climb/log.md
+++ b/docs/hill-climb/log.md
@@ -462,3 +462,19 @@ like, speech and bench OK) can now be retried as it was.
0–0.5 kHz (1.28), the onsets' remaining mean gap (0.97 and 0.52) and the vibrato share (0.65).
For H1−H2, try a wider F1 bandwidth or F1 that follows pitch (lead 1). For the onsets, look at the
phrases still far off rather than the medians, which are now about right.
+
+### Batch review (Codex), and what changed after it
+
+The review found no engine defect and called all six changes plausible. Three things changed:
+
+- **Speech and speed are judged against the batch's baseline** (`out/hill/baseline/`), not
+ the best run. With a 3-point or 10 % allowance per step measured against the best run,
+ small losses could add up over a batch: 38 → 41 → 44 → 47 % would pass every step.
+- **Fixtures are written atomically** (a temporary file, then a rename). While one planning
+ test blessed `planning.json`, another could start and read half of it.
+- **The pressed end of the tension control is back.** Experiment 2's `0.4·tension` capped the
+ closure at 0.4 even at full "Pressed", where it had been 0.95. That is a sound no judge
+ measures, since everything is rendered at tension 0.5–0.55. Above 0.6 the closure now
+ sharpens again, to 0.95 at full tension. Every judged render is byte-identical, so no score
+ moves. A test (`tests/voice_source.rs`) keeps the closure rising with tension all the way.
+