From 3b62b9c9d492d64e0236656f1924d53a6e0713ad Mon Sep 17 00:00:00 2001 From: Aqua Date: Fri, 13 Nov 2026 12:21:20 +0000 Subject: [PATCH] Tract: ramps at phone boundaries, 12 ms stop release, smoothers that start at their input, 12 ms attack; listening verdict and analysis Meta's tract-weak-spots-1 verdict (2 keep, 12 fix) with formants matching their targets: nibu clicks at the phone boundaries (a step in the merged control curve), every clip a 100 ms climb from silence (si.smoo starts at 0), a 33 ms stop opening heard as a fricative. ear_metrics.py and phone_probe.py measure those faults. Co-Authored-By: Claude Sonnet 5.5 --- .../tract-weak-spots-1-analysis-20261113.md | 66 +++++ .../tract-weak-spots-1-meta-20261113.json | 231 ++++++++++++++++++ .../tract-weak-spots-1-meta-20261113.md | 32 +++ src/AquaSynth.Core/FaustExport.cs | 14 +- src/AquaSynth.Core/IpaGestureExperiment.cs | 2 +- src/AquaSynth.Core/PatchScript.cs | 53 +++- .../AquaSynth.Dsl.Tests/NasalCouplingTests.cs | 2 +- .../PhoneTransitionTests.cs | 84 +++++++ tests/AquaSynth.Dsl.Tests/PlaceTableTests.cs | 24 +- tests/AquaSynth.Dsl.Tests/WeksaPhonesTests.cs | 6 +- tools/formant-check/ear_metrics.py | 104 ++++++++ tools/formant-check/phone_probe.py | 39 +++ 12 files changed, 632 insertions(+), 25 deletions(-) create mode 100644 docs/listening/tract-weak-spots-1-analysis-20261113.md create mode 100644 docs/listening/tract-weak-spots-1-meta-20261113.json create mode 100644 docs/listening/tract-weak-spots-1-meta-20261113.md create mode 100644 tests/AquaSynth.Dsl.Tests/PhoneTransitionTests.cs create mode 100644 tools/formant-check/ear_metrics.py create mode 100644 tools/formant-check/phone_probe.py diff --git a/docs/listening/tract-weak-spots-1-analysis-20261113.md b/docs/listening/tract-weak-spots-1-analysis-20261113.md new file mode 100644 index 0000000..bdd19de --- /dev/null +++ b/docs/listening/tract-weak-spots-1-analysis-20261113.md @@ -0,0 +1,66 @@ +# tract-weak-spots-1: why the predictions failed, and what was changed + +The verdict is `tract-weak-spots-1-meta-20261113.md`. Every falsifiable prediction in the kit failed although the formant numbers +behind them were right. The kit measured the steady part of each vowel (35-85 % of the clip) and the peak of each burst; the faults +Meta heard sit in the first 100 ms of every clip, at the phone boundaries, and in how long the burst lasts. Nothing in the old +measurement set looked there. Everything below was measured on the clips Meta heard (`weak-kit-out/clips`, WordRender at 140 Hz) before +any change, and again after. + +## Causes found (measured, not guessed) + +| # | what she heard | cause | evidence (before) | +|---|---|---|---| +| 1 | nibu: "both consonants are just clicks"; leak-before: "reversed percussive hit" | The merged control curve of a surface holds the previous phone's value to the boundary and steps to the next phone's first value there (two points at one time). A step in a ladder cell's area is a one-sample transient. | Pitch-period window peaks: 0.399 at 95 ms and 0.487 at 275 ms, against vowel pulses of ~0.1-0.2; both instants are phone boundaries of the script (`start=0.095`, `0.275`). The whole-render peak the kit reported (0.487) was this click. Click ratio 3.54 (`ear_metrics.py`). The old report called 0.487 vs 0.399 a "leak" difference. | +| 2 | every clip starts as a fade-in; the "kazoo" with "no audible closure" (ba, no burst); the /ɪ/ not like "bit" | `si.smoo` starts every control slider at 0. A word began with the tract shut, the vowel weights at 0 and the source off, and climbed for ~100 ms. The 140 ms "closure" of ba was largely this climb. | Isolated /ɪ/: level -66 dB at 0 ms, -45 at 40 ms, -30 at 100 ms, -28 from 140 ms; LPC bandwidth of F1 367 Hz at 0 ms, 232 at 60 ms, 103 at 100 ms, 90 from 140 ms. 100 of the clip's 309 ms were the climb; the steady-state window (35-85 %) started after it. | +| 3 | ba with burst: "fah then bah" | The stop opened over 0.65 to 1.0 of its gesture: 33 ms of a 95 ms /b/. A burst of that length is a fricative. | Burst-notes: ba burst 0.0707-0.1039 s (33 ms). A recogniser reads the clip as `v ɑ` (with the burst), `b ɑ` without. | +| 4 | nasals: "basketball buzzer, no audible articulation", /n/ and /m/ alike | The murmur had no entry and exit transitions (the step of cause 1) and began after the climb of cause 2; the machine ear read /n/ as /m/ (`v ɑ m ɑ`). | recogniser, before: ana -> `v ɑ m ɑ`. | +| 5 | bun with burst: "a truck releasing its pneumatics" | cause 3 (long burst), same mechanism. | burst 0.0721-0.0998 s (28 ms). | + +## What was changed (PR "phone transitions", this branch) + +1. `PatchScript.WithPhoneTransition`: every authored gesture spline starts, when an earlier gesture left the surface at another value, + with a 30 ms ramp from the previous value (at most 0.4 of the gesture, and before its second point). The first phone of a word and + surfaces no earlier phone touched are unchanged. Test: `PhoneTransitionTests.NoSurfaceStepsAtAPhoneBoundary` (worst step in 1 ms + around each boundary of nibu: below 0.03; before, 0.77: the vowel's 1 against the nasal's released 0.23). +2. A stop holds all its articulators shut until 12 ms before its end and opens in those 12 ms (`StopReleaseSeconds`, a design value); + it used to open over 0.65 to 1 of its gesture. Test: `AStopOpensInTwelveMillisecondsNotAThirdOfItsGesture`. +3. `smoo_init` replaces `si.smoo` on every control-surface and spline-point slider of the emitted DSP: the smoother starts at its input. + Patch parameters keep `si.smoo`. Test: `ControlSmoothersStartAtTheirInputNotAtZero`. +4. The word scaffold's vocal envelope gets a 12 ms attack (it was 0, so the now-instant start was itself a click: first-sample peak 0.22). +5. `tools/formant-check/ear_metrics.py` (click ratio, largest sample step, LPC bandwidths, HNR, energy above 4 kHz) and + `tools/formant-check/phone_probe.py` (a speech recogniser as a machine ear) so these faults are measured, not heard first by Meta. + +### After (same words, same 140 Hz, `fix-out-c`) + +| word | before | after | +|---|---|---| +| nibu_flat | click ratio 3.54, peaks 0.399 / 0.487; recogniser `i b u` | peaks at the boundaries 0.08; click ratio 1.76 (the vowel's own pulses); recogniser `n i l t uː` (the /n/ is back, the /b/ reads as `l t`: see below) | +| ba (burst) | recogniser `v ɑ`; burst 33 ms | `b ɑ`; opening 12 ms | +| ba (no burst) | `b ɑ` | `m ɑ` | +| ana / ama | `v ɑ m ɑ` / `v ɑ m ɑ` | `ɑ n ɑ` / `ɑ m ɑ` | +| isolated /i/ | `h iː`; level climb 100 ms | `i`; level within 3 dB of the steady value by 20 ms | +| isolated /ɪ/ | `h i` | `ʔ i` | + +## Not fixed, and why (open until she listens) + +- **Voice quality: "kazoo with a two-pack-a-day smoking habit" (the two clips she kept), "reedy, like Pink Trombone" (/ʊ/), "basketball + buzzer" (nasals).** Her comments on the two keeps say the vowel is right and the voice is wrong. Candidates, none tested by ear: + (a) the glottal source is a band-limited saw through a one-pole lowpass with no closed phase (`FaustExport.PrimitiveSourceExpression`), + where a Rosenberg/LF pulse has the open and closed phases real fold flow has; (b) harmonics-to-noise ratio of the steady part is 13-15 dB + (healthy voices ~20+), from the source's `0.08 * noise` term and the saw's aliasing; (c) LPC bandwidths of the steady vowel are 90 Hz (F1), + 130 (F2), 100 (F3) for /ɪ/: plausible, so the wall-loss hypothesis is weak (the F2 of /ɑ/, 29 Hz, and the F1 of /i/, 14-24 Hz, are LPC + artefacts of a pole sitting on a harmonic). Settling this needs a listening kit that varies one of them at a time; the next kit does. +- **/ɪ/ as the "eu" of cordon bleu.** The recogniser cannot judge this tract's vowel quality (every isolated vowel came back /i/). The + confirmed fault in that clip is cause 2: a third of it was a muffled climb through bandwidths of 300 Hz. Whether the steady /ɪ/ then + reads as "bit" is for her ear; lax vowels in isolation and without vowel-inherent spectral change are known to be misheard + (Hillenbrand et al. 1995, Strange et al. 1983), so the next kit also carries /ɪ/ in a word. +- **The medial /b/ of nibu reads as `l t` to the recogniser after the fix, where it read `b` with the click and the long burst.** The closure + voice bar sits 10 dB under the vowel (a murmur-like level; a stop's runs 20+ dB under), and a labial burst is injected at the glottal + end in a word with no other plosive (`FaustExport` burst injection), so it is filtered by the whole tract like aspiration. Both are + next, with the listening to decide. + +## What the old measurements missed, as a rule + +A steady-state window measures a steady state. Faults of onset, boundary and duration need metrics that look at onsets, boundaries +and durations: click ratio and step size at each phone boundary, time-to-full-level, burst length, bandwidths, HNR. These now exist +(`ear_metrics.py`) and the click and onset ones are pinned by tests. diff --git a/docs/listening/tract-weak-spots-1-meta-20261113.json b/docs/listening/tract-weak-spots-1-meta-20261113.json new file mode 100644 index 0000000..9504d9f --- /dev/null +++ b/docs/listening/tract-weak-spots-1-meta-20261113.json @@ -0,0 +1,231 @@ +{ + "schema": "aqua.listen.verdict.v1", + "kit": { + "id": "tract-weak-spots-1", + "title": "Articulatory vocal tract: stress, release, nasals, lax vowels" + }, + "exportedAt": "2026-11-13T11:27:36.539Z", + "seed": 1326320895, + "consent": true, + "listener": "Meta", + "device": null, + "notes": "", + "summary": { + "total": 14, + "keep": 2, + "fix": 12, + "drop": 0, + "unanswered": 0 + }, + "clips": [ + { + "position": 1, + "id": "lax-ih", + "title": "isolated /ɪ/ 180 ms, 140 Hz. Measured: Burg F1/F2 375/2024 Hz; tube chain 346/1987 (+8.5/+1.8 %); Hillenbrand 1995 male 429/2034 (-12.5/-0.5 %); Peterson & Barney 392/1993 (-4.3/+1.5 %). Present in the DSL table and renderable. PREDICTION: heard as the vowel of 'bit' (or a slightly high, 'ee'-leaning version of it). FALSIFIED if heard as 'ee' of 'beet', as 'eh' of 'bet', or as a different phone.", + "group": "lax", + "feel": "the short vowel in 'bit'", + "file": "v_ih.wav", + "pair": null, + "slot": null, + "verdict": "fix", + "reason": "It's more like the eu in cordon bleu than the i in bit ", + "landed": 2, + "device": null + }, + { + "position": 2, + "id": "burst-ba-on", + "title": "ba with the plosive burst (gain 0.06, a design value). Measured: burst alone peaks 0.0142 at 85 ms = -24.0 dB re vowel peak, falls to a tenth in 17 ms, burst rms in the 30 ms after its peak -31.0 dB re vowel rms. PREDICTION: a slightly crisper, more 'b'-like onset than B/off; the burst is quiet and short so the difference is small, 'a little pop' at most. FALSIFIED if it sounds like a hiss, a click, or a separate noise after the vowel started, or if no difference is heard.", + "group": "burst", + "feel": "the syllable 'bah' with a clean, crisp 'b' at the start", + "file": "ba.wav", + "pair": "burst-ba-off", + "slot": "A", + "verdict": "fix", + "reason": "More like fah then bah but you can hear something there", + "landed": 2, + "device": null + }, + { + "position": 3, + "id": "burst-ba-off", + "title": "ba with the release_flow splines dropped (WordRender --no-burst). Measured: closure peak 0.0078 (voice bar), release (voicing breaking through)peak 0.1087 = -6.3 dB re vowel peak 0.2247, no burst noise. PREDICTION: a soft, voiced 'b' with the vowel starting smoothly; may sound slightly 'w'-like or lack the pop. FALSIFIED if listeners cannot hear any difference from the burst twin (then burst gain 0.06 is inaudible).", + "group": "burst", + "feel": "the syllable 'bah' with a soft start", + "file": "ba_noburst.wav", + "pair": "burst-ba-on", + "slot": "B", + "verdict": "fix", + "reason": "There is no audible constriction. While the vowel is recognizable, it still sounds like a kazoo", + "landed": 2, + "device": null + }, + { + "position": 4, + "id": "stress-nibu-flat", + "title": "nibu, no stress marks. Measured: /i/ 150-250 ms rms vs the stressed render +0.21 dB; unstressed vowel 180 ms, f0 139.9 Hz. PREDICTION: reads asan even two-syllable word with no strong first syllable. FALSIFIED if listeners hear it as stressed on a syllable or cannot tell it from the stressed twin.", + "group": "stress", + "feel": "a made-up two-syllable word, 'nee-boo', both syllables even", + "file": "nibu_flat.wav", + "pair": "stress-nibu", + "slot": "A", + "verdict": "fix", + "reason": "These both sound like 'ee'oo, with both consonants you're going for being just clicks", + "landed": 2, + "device": null + }, + { + "position": 5, + "id": "stress-nibu", + "title": "nibu with primary stress on /i/ (NI-bu). Measured: /i/ 247 ms vs 180 ms (+75 ms; design +68), f0 148.1 vs 139.9 Hz (x1.059), amplitude factor 1.30; level of /i/ in the 150-250 ms window only +0.21 dB (five-vowel mean +1.93 dB, per vowel +1.2 to +3.0). PREDICTION: first syllable heard as the prominent one, mostly through length and pitch, little through loudness; B should be picked as 'stressed on the first syllable'. FALSIFIED if it sounds no more prominent than the flat twin, if it sounds like a question or a pitch accent rather than stress, or if the level is what is heard (then the f0-scatter question is wrong).", + "group": "stress", + "feel": "the same made-up word, with the first syllable stronger: 'NEE-boo'", + "file": "nibu.wav", + "pair": "stress-nibu-flat", + "slot": "B", + "verdict": "fix", + "reason": "", + "landed": 2, + "device": null + }, + { + "position": 6, + "id": "stress-i-flat", + "title": "isolated /i/ 180 ms at 140 Hz, no stress. Measured: level 100-170 ms is the reference. PREDICTION: plain short vowel. FALSIFIED if it already sounds emphasised.", + "group": "stress", + "feel": "a single short 'ee' vowel, plain", + "file": "v_i.wav", + "pair": "stress-i", + "slot": "A", + "verdict": "keep", + "reason": "Still spoken by a kazoo with a two pack a day smoking habit, but it's an ee", + "landed": 4, + "device": null + }, + { + "position": 7, + "id": "stress-i", + "title": "isolated /i/ with primary stress: 247 ms, f0 x1.06, amplitude 1.30. Measured against the flat /i/: +1.22 dB total (f0 rise alone -0.80 dB, the amplitude and the rest +2.02 dB). PREDICTION: heard as longer and a little higher; the 1.2 dB louder is under what a listener can judge, so 'longer and higher' is the answer, 'louder' is not. FALSIFIED if it sounds the same length and pitch, or clearly louder.", + "group": "stress", + "feel": "the same 'ee' vowel, held longer and said with emphasis", + "file": "v_i_s.wav", + "pair": "stress-i-flat", + "slot": "B", + "verdict": "keep", + "reason": "", + "landed": 4, + "device": null + }, + { + "position": 8, + "id": "lax-oo-short", + "title": "isolated /ʊ/ 180 ms, 140 Hz. Measured: Burg F1/F2 486/894 Hz; tube chain 478/850 (+1.7/+5.2 %); Hillenbrand 469/1123 (+3.7/-20.4 %); Peterson &Barney 437/1023 (+11.3/-12.6 %). Present in the DSL table and renderable. PREDICTION: heard as the vowel of 'book', probably darker or rounder than a natural one (F2 20 % under the population mean, the back-vowel gap). FALSIFIED if heard as 'oo' of 'boot', 'o' of 'boat' or 'uh' of 'but'.", + "group": "lax", + "feel": "the short vowel in 'book'", + "file": "v_oo_short.wav", + "pair": null, + "slot": null, + "verdict": "fix", + "reason": "It's distinguishable, but it strongly has that reedy quality which I associate with pink trombone and that new one I shared", + "landed": 3, + "device": null + }, + { + "position": 9, + "id": "leak-nibu-flat-after", + "title": "nibu (flat) after the fix: release_flow is zero outside its own plosive. Same audio as stress-nibu-flat, kept as its own clip so the before/after pair is one-to-one. Measured: leak 0.0 from 275 ms on, burst of the b itself unchanged (bin 0.0226 at 81 ms before and after). PREDICTION: clean hum into thevowel, no noisy onset; preferred over 'before' if the leak is audible. FALSIFIED if 'before' is preferred or no difference is heard.", + "group": "release-leak", + "feel": "a made-up word that should start with a clean, smooth hum into the vowel: 'nee-boo'", + "file": "nibu_flat_after.wav", + "pair": "leak-nibu-flat-before", + "slot": "A", + "verdict": "fix", + "reason": "Just slightly less reverse attack on this one", + "landed": 2, + "device": null + }, + { + "position": 10, + "id": "leak-nibu-flat-before", + "title": "nibu (flat) rendered at main c0e6b98, before the release_flow fix. Measured: burst-gain leak vs the fixed render, peak 0.0688 and rms 0.0067 inthe leading /n/ (0-95 ms; the /n/ itself is rms 0.0058, so the hiss is louder than the murmur), peak 0.0504 over /i/ onset 95-150 ms, 0.0019 after; whole-render peak 0.487 vs 0.399. PREDICTION: an audible hiss or click as the /n/ opens into the vowel, the first sound of the word being a noisy 'sn'-like or 'tsh' onset instead of a clean nasal hum. FALSIFIED if the two are indistinguishable (then the leak is inaudible and the fix is cosmetic).", + "group": "release-leak", + "feel": "a made-up word that should start with a clean, smooth hum into the vowel: 'nee-boo'", + "file": "nibu_flat_before.wav", + "pair": "leak-nibu-flat-after", + "slot": "B", + "verdict": "fix", + "reason": "'Ee'oo with some odd clicks that sound more like a reversed percussive hit than a consonant", + "landed": 2, + "device": null + }, + { + "position": 11, + "id": "nasal-n", + "title": "/ɑnɑ/. Measured: murmur -9.64 dB re the flanking vowels (2.17 dB above /m/; the gap is 2.01/2.17/2.05/1.61 dB at f0 110/140/170/200 Hz, so not harmonic sampling), Burg N1 332 Hz, bands 38.4/28.2/16.8/0.9 dB. PREDICTION: heard as 'ah-nah', a tongue-tip hum, a shade stronger than the /m/ one; the 2 dB isnot expected to be noticed. FALSIFIED if heard as 'ama' or 'anga', if it sounds much louder than the /m/ clip, or if there is hiss.", + "group": "nasal", + "feel": "'ah-nah': the tongue touches behind the teeth for a soft hum between two open vowels", + "file": "ana.wav", + "pair": null, + "slot": null, + "verdict": "fix", + "reason": "It just sounds like a basket ball buzzer, no audible articulation", + "landed": 2, + "device": null + }, + { + "position": 12, + "id": "burst-bun-off", + "title": "bun, /bʊn/, no burst. Measured: closure peak 0.0043, release peak 0.1074 = -5.9 dB re vowel peak 0.2126. PREDICTION: soft 'b' then a short backvowel then a nasal; the final /n/ is a clean hum (no leak since the fix). FALSIFIED as for burst-ba-off.", + "group": "burst", + "feel": "a short word like 'bunn' or 'boon' said quickly, soft start", + "file": "bun_noburst.wav", + "pair": "burst-bun-on", + "slot": "A", + "verdict": "fix", + "reason": "Oou'mou is what this sounds closest to, with the apostrophe representing a clicking sound that's in there", + "landed": 2, + "device": null + }, + { + "position": 13, + "id": "burst-bun-on", + "title": "bun, /bʊn/, with burst. Measured: burst peak 0.0130 at 81 ms = -24.3 dB re vowel peak, tenth in 15 ms; tail leak after the fix 0.0 (was 0.0126 at the end before). PREDICTION: slightly crisper onset than off; final /n/ clean. FALSIFIED as for burst-ba-on.", + "group": "burst", + "feel": "a short word like 'bunn' or 'boon' said quickly, crisp 'b' start", + "file": "bun.wav", + "pair": "burst-bun-off", + "slot": "B", + "verdict": "fix", + "reason": "The main difference seems to be a sort of air release added to the beginning which resembles more a truck releasing its pneumatics than a human", + "landed": 2, + "device": null + }, + { + "position": 14, + "id": "nasal-m", + "title": "/ɑmɑ/. Measured: murmur -11.81 dB re the flanking vowels (design band -16..-8), Burg N1 295 Hz, band levels 0-400/400-800/800-1600/1600-3200 Hzof the murmur 36.3/23.6/21.3/2.7 dB. PREDICTION: heard as 'ah-mah', a lip-closed hum between the vowels, clearly softer than the vowels. FALSIFIED if heard as 'abah' or 'awah', if the hum is as loud as the vowels, or if there is a gap or click.", + "group": "nasal", + "feel": "'ah-mah': lips close for a soft hum between two open vowels", + "file": "ama.wav", + "pair": null, + "slot": null, + "verdict": "fix", + "reason": "That m is almost coming through, still more of a basketball buzzer", + "landed": 2, + "device": null + } + ], + "pairs": [ + { + "a": "burst-ba-on", + "b": "burst-ba-off", + "preferred": "burst-ba-on" + }, + { + "a": "stress-nibu-flat", + "b": "stress-nibu", + "preferred": "no-difference" + } + ], + "_truncated": "the mail reader cut the body at 12000 characters inside the pairs list; pairs after the third are not recorded" +} \ No newline at end of file diff --git a/docs/listening/tract-weak-spots-1-meta-20261113.md b/docs/listening/tract-weak-spots-1-meta-20261113.md new file mode 100644 index 0000000..5f063cc --- /dev/null +++ b/docs/listening/tract-weak-spots-1-meta-20261113.md @@ -0,0 +1,32 @@ +# Listening verdict: tract-weak-spots-1 (page tract-listen-1b6d180) + +Listener: Meta (operator), 2026-11-13. Exported 11:27Z by the page (`aqua.listen.verdict.v1`, seed 1326320895), pasted in +#aquasynth (truncated after clip 5) and emailed to aqua@minds.gamecult.org at 11:30Z; the data here is the email, +parsed whole by `mind-mail read` except the tail: the mail reader cut the body at 12000 characters inside `pairs`, so +only the first two pair preferences survive. Raw data: `tract-weak-spots-1-meta-20261113.json`. Totals: 2 keep, 12 fix, 0 drop. +`position` is the page's random order for this listener; ids are the kit's. + +| # | clip | verdict | what she heard | +|---|---|---|---| +| 1 | `lax-ih` (`v_ih.wav`) | fix | It's more like the eu in cordon bleu than the i in bit | +| 2 | `burst-ba-on` (`ba.wav`) | fix | More like fah then bah but you can hear something there | +| 3 | `burst-ba-off` (`ba_noburst.wav`) | fix | There is no audible constriction. While the vowel is recognizable, it still sounds like a kazoo | +| 4 | `stress-nibu-flat` (`nibu_flat.wav`) | fix | These both sound like 'ee'oo, with both consonants you're going for being just clicks | +| 5 | `stress-nibu` (`nibu.wav`) | fix | (no comment) | +| 6 | `stress-i-flat` (`v_i.wav`) | keep | Still spoken by a kazoo with a two pack a day smoking habit, but it's an ee | +| 7 | `stress-i` (`v_i_s.wav`) | keep | (no comment) | +| 8 | `lax-oo-short` (`v_oo_short.wav`) | fix | It's distinguishable, but it strongly has that reedy quality which I associate with pink trombone and that new one I shared | +| 9 | `leak-nibu-flat-after` (`nibu_flat_after.wav`) | fix | Just slightly less reverse attack on this one | +| 10 | `leak-nibu-flat-before` (`nibu_flat_before.wav`) | fix | 'Ee'oo with some odd clicks that sound more like a reversed percussive hit than a consonant | +| 11 | `nasal-n` (`ana.wav`) | fix | It just sounds like a basket ball buzzer, no audible articulation | +| 12 | `burst-bun-off` (`bun_noburst.wav`) | fix | Oou'mou is what this sounds closest to, with the apostrophe representing a clicking sound that's in there | +| 13 | `burst-bun-on` (`bun.wav`) | fix | The main difference seems to be a sort of air release added to the beginning which resembles more a truck releasing its pneumatics than a human | +| 14 | `nasal-m` (`ama.wav`) | fix | That m is almost coming through, still more of a basketball buzzer | + +Pairs: `burst-ba-on` preferred over `burst-ba-off`; `stress-nibu-flat` vs `stress-nibu`: no difference. +(`leak-nibu-flat-before`/`after` and the bun pair carry no recorded preference; she heard "just slightly less reverse +attack" on the fixed one, the pneumatic-truck "air release" on the bun burst.) + +Every prediction that was falsifiable failed, though the formant numbers behind them were measured correctly. The +two keeps are the isolated /i/ pair, and even those were "a kazoo with a two pack a day smoking habit". Analysis and +the fixes it led to: `tract-weak-spots-1-analysis-20261113.md`. diff --git a/src/AquaSynth.Core/FaustExport.cs b/src/AquaSynth.Core/FaustExport.cs index e006102..9053dc1 100644 --- a/src/AquaSynth.Core/FaustExport.cs +++ b/src/AquaSynth.Core/FaustExport.cs @@ -45,6 +45,10 @@ public static partial class FaustEmitter source.AppendLine("bez(t,a,b,c,d) = (1.0 - t) * (1.0 - t) * (1.0 - t) * a + 3.0 * (1.0 - t) * (1.0 - t) * t * b + 3.0 * (1.0 - t) * t * t * c + t * t * t * d;"); source.AppendLine("seg_bez(t,t0,d,a,b,c,e) = bez(clip01((t - t0) / max(0.0001, d)), a, b, c, e);"); source.AppendLine("smooth01(x) = clip01(x) * clip01(x) * (3.0 - 2.0 * clip01(x));"); + // si.smoo starts every control at 0 and climbs to it: a word began with the tract shut, the vowel weights at 0 and the source off, + // and the first ~100 ms of every render were that climb (the level rose 40 dB over the first 100 ms of an isolated vowel, and + // the bandwidths fell from ~300 Hz to 90). This smoother starts at its input and smooths from there. + source.AppendLine("smoo_init(x) = loop ~ _ with { pole = ba.tau2pole(0.005); loop(prev) = select2(1 - 1', prev * pole + x * (1.0 - pole), x); };"); source.AppendLine("seg_smooth(t,t0,d,a,b) = a + (b - a) * smooth01((t - t0) / max(0.0001, d));"); source.AppendLine("seg_exp(t,t0,d,a,b) = exp(log(max(0.00001, a)) + (log(max(0.00001, b)) - log(max(0.00001, a))) * clip01((t - t0) / max(0.0001, d)));"); source.AppendLine("seg_curve(c,t,t0,d,a,b) = select2(c < 0.5, seg_exp(t,t0,d,a,b), seg(t,t0,d,a,b));"); @@ -152,7 +156,7 @@ public static partial class FaustEmitter var baseId = $"{id}_base"; var normalized = $"{id}_normalized"; var physical = $"{id}_physical"; - var publicControl = $"hslider(\"{Escape(surface.Path)}\", {F(surface.DefaultNormalized)}, 0, 1, 0.001) : si.smoo"; + var publicControl = $"hslider(\"{Escape(surface.Path)}\", {F(surface.DefaultNormalized)}, 0, 1, 0.001) : smoo_init"; var boundControl = parameters.TryBindingExpression(surface.FieldPath, out var bindingExpression) ? $"clip01(({bindingExpression} - {F(surface.MinValue)}) / max(0.000001, {F(surface.MaxValue - surface.MinValue)}))" : publicControl; @@ -172,7 +176,7 @@ public static partial class FaustEmitter var splineId = $"{id}_spline_{splineIndex}"; EmitControlSpline(source, spline, splineId, surface.DefaultNormalized); var depth = $"{splineId}_depth"; - source.AppendLine($"{depth} = hslider(\"/splines/{Escape(spline.Name)}/depth\", 1, 0, 1, 0.001) : si.smoo;"); + source.AppendLine($"{depth} = hslider(\"/splines/{Escape(spline.Name)}/depth\", 1, 0, 1, 0.001) : smoo_init;"); terms.Add($"(({splineId}_value - {F(surface.DefaultNormalized)}) * {depth})"); } @@ -197,11 +201,11 @@ public static partial class FaustEmitter { var point = points[i]; source.AppendLine($"{splineId}_p{i}_time = hslider(\"/splines/{Escape(spline.Name)}/{i}/time\", {F(point.TimeSeconds)}, 0, 120, 0.001);"); - source.AppendLine($"{splineId}_p{i}_value = hslider(\"/splines/{Escape(spline.Name)}/{i}/value\", {F(Math.Clamp(point.Value, 0, 1))}, 0, 1, 0.001) : si.smoo;"); + source.AppendLine($"{splineId}_p{i}_value = hslider(\"/splines/{Escape(spline.Name)}/{i}/value\", {F(Math.Clamp(point.Value, 0, 1))}, 0, 1, 0.001) : smoo_init;"); source.AppendLine($"{splineId}_p{i}_out_time = hslider(\"/splines/{Escape(spline.Name)}/{i}/out_time\", {F(Math.Max(0, point.OutTimeOffsetSeconds))}, 0, 10, 0.001);"); - source.AppendLine($"{splineId}_p{i}_out_value = hslider(\"/splines/{Escape(spline.Name)}/{i}/out_value\", {F(point.OutValue == 0 ? point.Value : Math.Clamp(point.OutValue, 0, 1))}, 0, 1, 0.001) : si.smoo;"); + source.AppendLine($"{splineId}_p{i}_out_value = hslider(\"/splines/{Escape(spline.Name)}/{i}/out_value\", {F(point.OutValue == 0 ? point.Value : Math.Clamp(point.OutValue, 0, 1))}, 0, 1, 0.001) : smoo_init;"); source.AppendLine($"{splineId}_p{i}_in_time = hslider(\"/splines/{Escape(spline.Name)}/{i}/in_time\", {F(Math.Max(0, point.InTimeOffsetSeconds))}, 0, 10, 0.001);"); - source.AppendLine($"{splineId}_p{i}_in_value = hslider(\"/splines/{Escape(spline.Name)}/{i}/in_value\", {F(point.InValue == 0 ? point.Value : Math.Clamp(point.InValue, 0, 1))}, 0, 1, 0.001) : si.smoo;"); + source.AppendLine($"{splineId}_p{i}_in_value = hslider(\"/splines/{Escape(spline.Name)}/{i}/in_value\", {F(point.InValue == 0 ? point.Value : Math.Clamp(point.InValue, 0, 1))}, 0, 1, 0.001) : smoo_init;"); } if (points.Length == 1) diff --git a/src/AquaSynth.Core/IpaGestureExperiment.cs b/src/AquaSynth.Core/IpaGestureExperiment.cs index 84a2c69..867e399 100644 --- a/src/AquaSynth.Core/IpaGestureExperiment.cs +++ b/src/AquaSynth.Core/IpaGestureExperiment.cs @@ -278,7 +278,7 @@ public static class IpaGestureExperiment probe_timeline name=flow network=voice blocks=12 block_size=64 {{SideStubDeclarations(sideStub)}}vocal_network name=voice paths=oral_path,nasal_path{{(sideStub ? ",side_stub_path" : "")}} sources=folds contacts=contact branches=velopharynx{{(sideStub ? "," + PatchScript.SideStubBranch : "")}} radiation=mouth,nostril{{(sideStub ? ",side_stub_end" : "")}} probe=flow {{string.Join("\n", gestureLines)}} - vocal network=voice freq={{Format(frequency)}} gain=.7 sustain={{Format(sustain)}} + vocal network=voice freq={{Format(frequency)}} gain=.7 attack=.012 sustain={{Format(sustain)}} """; private static IReadOnlyList SummarizeMetrics(IReadOnlyList metrics) => diff --git a/src/AquaSynth.Core/PatchScript.cs b/src/AquaSynth.Core/PatchScript.cs index 38a619b..fe78577 100644 --- a/src/AquaSynth.Core/PatchScript.cs +++ b/src/AquaSynth.Core/PatchScript.cs @@ -1494,11 +1494,49 @@ public static class PatchScript duration * 0.25f, Math.Clamp(point.value, 0, 1))) .ToArray(); + splinePoints = WithPhoneTransition(surfacePath, start, duration, splinePoints); var spline = new ControlSpline(splineName, surfacePath, splinePoints, ControlSplineInterpolation.Bezier); _controlSplines.Add(spline); _controlSplinesByName[spline.Name] = spline; } + // Seconds an articulator takes to move from where the previous phone left it to this phone's first value. A tract does not step + // between phones: the merged surface curve held the previous value up to the boundary and jumped, and a jump in a ladder cell's + // area is a transient the ear hears as a click (nibu: peak 0.40 and 0.49 against a 0.2 vowel, at the 95 and 275 ms boundaries), + // and it leaves the consonant without the formant transitions that tell /b/ from a fade-in. A DESIGN VALUE inside the 20-50 ms + // of a CV formant transition; no measurement of this tract retrieved. + private const float PhoneTransitionSeconds = 0.03f; + + // Seconds a stop takes to open from full closure; its burst lasts about this long. A DESIGN VALUE inside the 5-15 ms of a + // stop burst; no measurement of this tract retrieved. The opening's noise is still shaped by the exporter. + private const float StopReleaseSeconds = 0.012f; + + // Prepends the boundary ramp: a point at the gesture start holding the value the surface has there, then the gesture's first + // point PhoneTransitionSeconds later (at most 0.4 of the gesture, and before its second point). The first phone of a word, and + // a surface the earlier phones never touched, keep their value from the start. + private ControlSplinePoint[] WithPhoneTransition(string surfacePath, float start, float duration, ControlSplinePoint[] points) + { + ControlSplinePoint? previous = null; + foreach (var spline in _controlSplines) + { + if (!spline.SurfacePath.Equals(surfacePath, StringComparison.OrdinalIgnoreCase)) continue; + foreach (var point in spline.Points) + { + if (point.TimeSeconds <= start + 0.000001f && (previous is null || point.TimeSeconds >= previous.TimeSeconds)) previous = point; + } + } + + if (previous is null || points.Length < 2 || MathF.Abs(previous.Value - points[0].Value) <= 0.0005f) return points; + var ramp = MathF.Min(PhoneTransitionSeconds, 0.4f * duration); + ramp = MathF.Min(ramp, points[1].TimeSeconds - points[0].TimeSeconds); + if (ramp < 0.002f) return points; + var handle = ramp / 3; + var first = points[0]; + var lead = new ControlSplinePoint(first.TimeSeconds, previous.Value, handle, previous.Value, handle, previous.Value); + var arrival = first with { TimeSeconds = first.TimeSeconds + ramp, InTimeOffsetSeconds = handle, InValue = first.Value }; + return [lead, arrival, .. points.Skip(1)]; + } + private string UniqueSplineName(string name) { var safe = SafeName(name); @@ -1564,15 +1602,20 @@ public static class PatchScript // A stop whose seal is the tongue (not the lips) is closed completely and until the contact opens (0.65): at the nasal's 0.03 cm // aperture a /t/ closure measured -10.4 dB re its vowels against /p/ -19.7 (the lips seal /p/ whatever the tongue does), and // rendered -21.5 dB with the aperture at 0 (area floor 1e-6 cm^2). - var closureHold = tokens.Contains("nasal") || tokens.Contains("lateral") ? 0.8f : stopsBehindTheLips ? 0.65f : 0.5f; + // Every stop holds all its articulators shut until StopReleaseSeconds before its end and opens in that time: the burst is the + // opening, and an opening spread over a third of the gesture (33 ms of the 95 ms /b/) made the burst a fricative's length + // (the phone recogniser heard /v/ before the vowel, Meta heard "fah then bah"). + var isStop = tokens.Contains("plosive") || tokens.Contains("stop"); + var stopHold = 1 - MathF.Min(StopReleaseSeconds, 0.3f * duration) / duration; + var closureHold = tokens.Contains("nasal") || tokens.Contains("lateral") ? 0.8f : isStop ? stopHold : 0.5f; var closed = stopsBehindTheLips ? 0f : constriction; AddAuthoredSpline($"{name}_constriction_diameter", "/vocal/areas/0/area/constriction_diameter", start, duration, (0, closed), (closureHold, closed), (1, Math.Min(0.65f, constriction + 0.2f))); if (tokens.Contains("bilabial") || tokens.Contains("labiodental") || tokens.Contains("labial") || tokens.Contains("rounded")) { var lipTarget = tokens.Contains("approximant") ? 0.38f : tokens.Contains("fricative") ? 0.18f : 0.04f; - AddAuthoredSpline($"{name}_lip_area", "/vocal/areas/0/area/lip_opening", start, duration, (0, lipTarget), (0.7f, lipTarget), (1, 0.45f)); - AddAuthoredSpline($"{name}_lip_radiation", "/vocal/radiation/0/aperture", start, duration, (0, lipTarget), (0.7f, lipTarget), (1, 0.75f)); + AddAuthoredSpline($"{name}_lip_area", "/vocal/areas/0/area/lip_opening", start, duration, (0, lipTarget), (isStop ? stopHold : 0.7f, lipTarget), (1, 0.45f)); + AddAuthoredSpline($"{name}_lip_radiation", "/vocal/radiation/0/aperture", start, duration, (0, lipTarget), (isStop ? stopHold : 0.7f, lipTarget), (1, 0.75f)); } if (tokens.Contains("nasal")) @@ -1582,8 +1625,8 @@ public static class PatchScript } else if (tokens.Contains("plosive") || tokens.Contains("stop")) { - AddAuthoredSpline($"{name}_contact", "/vocal/contacts/0/opening", start, duration, (0, 0.02f), (0.65f, 0.02f), (1, 0.9f)); - AddAuthoredSpline($"{name}_stored_pressure", "/vocal/contacts/0/stored_pressure", start, duration, (0, 0.4f), (0.65f, 0.75f), (1, 0.05f)); + AddAuthoredSpline($"{name}_contact", "/vocal/contacts/0/opening", start, duration, (0, 0.02f), (stopHold, 0.02f), (1, 0.9f)); + AddAuthoredSpline($"{name}_stored_pressure", "/vocal/contacts/0/stored_pressure", start, duration, (0, 0.4f), (stopHold, 0.75f), (1, 0.05f)); // The release burst is turbulence at the opening constriction: its gain is held for the plosive and the exporter shapes // it by the stored pressure and the opening (see PrimitiveContactExpression). The gain exists only around this plosive: // a surface holds its last value after its last point (and its first before its first), so a gain left at its level diff --git a/tests/AquaSynth.Dsl.Tests/NasalCouplingTests.cs b/tests/AquaSynth.Dsl.Tests/NasalCouplingTests.cs index 638bf3f..58e3d9c 100644 --- a/tests/AquaSynth.Dsl.Tests/NasalCouplingTests.cs +++ b/tests/AquaSynth.Dsl.Tests/NasalCouplingTests.cs @@ -68,7 +68,7 @@ public sealed class NasalCouplingTests } private static float Spline(SynthPatch patch, string namePrefix, string surfacePath) => - patch.ControlSplines.Single(spline => spline.Name.StartsWith(namePrefix, StringComparison.Ordinal) && spline.SurfacePath == surfacePath).Points[0].Value; + patch.ControlSplines.Single(spline => spline.Name.StartsWith(namePrefix, StringComparison.Ordinal) && spline.SurfacePath == surfacePath).Points[^1].Value; // a held place: the last point is the gesture's value whether or not a boundary ramp precedes it // Distance of a vowel_set consonant constriction from the lip plane in cm, from the constriction_index spline: the surface is a section // index in [0, sections] and the area model reads position = index / (sections - 1). diff --git a/tests/AquaSynth.Dsl.Tests/PhoneTransitionTests.cs b/tests/AquaSynth.Dsl.Tests/PhoneTransitionTests.cs new file mode 100644 index 0000000..43a3817 --- /dev/null +++ b/tests/AquaSynth.Dsl.Tests/PhoneTransitionTests.cs @@ -0,0 +1,84 @@ +using AquaSynth.Dsl; +using AquaSynth.Faust; + +namespace AquaSynth.Dsl.Tests; + +// What Meta heard in tract-weak-spots-1 (2026-11-13) while every formant matched: clicks at the phone boundaries of nibu, a /b/ burst the +// length of a fricative, and a first 100 ms that climbed from silence. These pin the three causes at the control-spline and DSP-source +// level (docs/listening/tract-weak-spots-1-analysis-20261113.md); the renders are measured by tools/formant-check/ear_metrics.py. +public sealed class PhoneTransitionTests +{ + private static SynthPatch Nibu() => PatchScript.Parse(IpaGestureExperiment.BuildWordScript( + [ + (new IpaGestureExperimentTarget("w_n", "n", "", .095f), 1f), + (new IpaGestureExperimentTarget("w_i", "i", "", .18f), 1f), + (new IpaGestureExperimentTarget("w_b", "b", "", .095f), 1f), + (new IpaGestureExperimentTarget("w_u", "u", "", .18f), 1f) + ], frequency: 140)); + + [Fact] + public void NoSurfaceStepsAtAPhoneBoundary() + { + var timeline = new ControlSplineTimeline(Nibu().ControlSplines); + var worst = (Surface: "", Boundary: 0f, Step: 0f); + foreach (var boundary in new[] { .095f, .275f, .37f }) + { + foreach (var surface in timeline.SurfacePaths) + { + var step = MathF.Abs(timeline.ValueAt(surface, boundary + .0005f) - timeline.ValueAt(surface, boundary - .0005f)); + if (step > worst.Step) worst = (surface, boundary, step); + } + } + + // 0.5 ms either side of a boundary; a 30 ms ramp across the full 0..1 range moves 0.017 in that time, a step moves it by the + // whole difference (the pre-fix nibu stepped /vocal/areas/0/area/constriction_diameter by 0.77 at the 95 ms boundary). + Assert.True(worst.Step < .03f, $"{worst.Surface} steps {worst.Step:0.000} at {worst.Boundary} s"); + } + + [Fact] + public void ThePhoneAfterABoundaryArrivesAtItsFirstValueWithinTheTransition() + { + var timeline = new ControlSplineTimeline(Nibu().ControlSplines); + const string diameter = "/vocal/areas/0/area/constriction_diameter"; + var closedN = timeline.ValueAt(diameter, .05f); + Assert.True(closedN < .1f, "the /n/ constriction is shut"); + Assert.True(timeline.ValueAt(diameter, .095f + .002f) < .5f, "still closing into the vowel two ms after the boundary"); + Assert.Equal(1f, timeline.ValueAt(diameter, .095f + .035f), 2); + } + + [Fact] + public void TheFirstPhoneOfAWordStartsAtItsOwnValue() + { + var timeline = new ControlSplineTimeline(Nibu().ControlSplines); + Assert.Equal(timeline.ValueAt("/vocal/areas/0/area/constriction_diameter", 0f), timeline.ValueAt("/vocal/areas/0/area/constriction_diameter", .02f), 3); + } + + [Fact] + public void AStopOpensInTwelveMillisecondsNotAThirdOfItsGesture() + { + var timeline = new ControlSplineTimeline(Nibu().ControlSplines); + const string contact = "/vocal/contacts/0/opening"; + const float start = .275f, duration = .095f; + Assert.True(timeline.ValueAt(contact, start + duration - .013f) < .1f, "closed until 12 ms before the end"); + Assert.True(timeline.ValueAt(contact, start + duration) > .8f, "open at the end"); + var opening = 0f; + for (var t = start + .03f; t <= start + duration; t += .0005f) + { + if (timeline.ValueAt(contact, t) > .3f) { opening = t; break; } + } + + Assert.True(start + duration - opening < .012f, $"the opening crosses 0.3 only {start + duration - opening:0.000} s before the end"); + } + + [Fact] + public void ControlSmoothersStartAtTheirInputNotAtZero() + { + var source = FaustEmitter.Emit(Nibu(), new FaustExportOptions("transition_probe")).Source; + Assert.Contains("smoo_init(x) =", source); + Assert.Contains("smoo_init;", source); + // Every control surface and spline-point slider uses it; patch parameters keep si.smoo. + var remaining = source.Split('\n').Where(line => line.Contains("hslider", StringComparison.Ordinal) && line.Contains(": si.smoo;", StringComparison.Ordinal) + && (line.Contains("\"/vocal/", StringComparison.Ordinal) || line.Contains("\"/splines/", StringComparison.Ordinal))).ToArray(); + Assert.Empty(remaining); + } +} diff --git a/tests/AquaSynth.Dsl.Tests/PlaceTableTests.cs b/tests/AquaSynth.Dsl.Tests/PlaceTableTests.cs index 6813300..21b863a 100644 --- a/tests/AquaSynth.Dsl.Tests/PlaceTableTests.cs +++ b/tests/AquaSynth.Dsl.Tests/PlaceTableTests.cs @@ -16,9 +16,10 @@ public sealed class PlaceTableTests(ITestOutputHelper output) private static float ConstrictionIndex(string script, string name) => PatchScript.Parse(script).ControlSplines - .Single(s => s.Name.StartsWith($"{name}_constriction_index", StringComparison.Ordinal) && s.SurfacePath == "/vocal/areas/0/area/constriction_index").Points[0].Value; + .Single(s => s.Name.StartsWith($"{name}_constriction_index", StringComparison.Ordinal) && s.SurfacePath == "/vocal/areas/0/area/constriction_index").Points[^1].Value; // the held place; a boundary ramp may precede it - // Pre-cut values on af0e44f: the vowel_set constriction_index spline value of /b/ and /n/ (and the hash of the whole script and of the + // Re-pinned on the phone-transition cut (boundary ramps, 12 ms stop release, smoo_init, vocal attack): these ids moved on purpose; the invariant + // that survives is that a word of labials writes no position surface (below), not these bytes. Pre-cut values on af0e44f: the vowel_set constriction_index spline value of /b/ and /n/ (and the hash of the whole script and of the // Faust source for /apa/ and /aba/, which this cut must not change by a byte; the ids are a SHA-256 prefix). private const float BIndex = 0.8333333f, NIndex = 0.7118056f; @@ -28,7 +29,7 @@ public sealed class PlaceTableTests(ITestOutputHelper output) var b = ConstrictionIndex(Word("b"), "w_1_c"); var n = ConstrictionIndex(Word("n"), "w_1_c"); output.WriteLine($"b {b:R} n {n:R}"); - foreach (var (ipa, scriptSha, faustSha) in new[] { ("p", "61A96E0AE8C68F52", "28022E56A77DB5B1"), ("b", "5D5A6B653DC5D37D", "2FB84E792B878BFE") }) + foreach (var (ipa, scriptSha, faustSha) in new[] { ("p", "0E86DB0F40C0F12A", "7FDFCB446676787E"), ("b", "A63403EBAAD016FB", "574AC2CE7AD191FC") }) { var script = Word(ipa); var faust = FaustEmitter.Emit(PatchScript.Parse(script), new FaustExportOptions("pin", SampleRate: 48000)).Source; @@ -47,8 +48,8 @@ public sealed class PlaceTableTests(ITestOutputHelper output) { foreach (var (ipa, scriptSha, faustSha) in new[] { - ("p", "61A96E0AE8C68F52", "28022E56A77DB5B1"), ("b", "5D5A6B653DC5D37D", "2FB84E792B878BFE"), - ("n", "BDF24A66659D7BD6", "ABEB5D03DC9637DB"), ("t", "9DFBCDB5131F9776", "30E144D54F7E026F"), + ("p", "0E86DB0F40C0F12A", "7FDFCB446676787E"), ("b", "A63403EBAAD016FB", "574AC2CE7AD191FC"), + ("n", "5C3FA24E40D9DE26", "AD4C6E3371E089CF"), ("t", "45941CCFD93561B3", "3FF82CED153C1543"), }) { var script = Word(ipa); @@ -109,8 +110,9 @@ public sealed class PlaceTableTests(ITestOutputHelper output) var script = IpaGestureExperiment.BuildWordScript( [(Phone("0_b", "b", 0.095f), 1f), (Phone("1_a", "a", 0.18f), 1f), (new IpaGestureExperimentTarget("w_2_t", "t", "voiceless_alveolar_plosive", 0.095f), 1f), (Phone("3_a", "a", 0.18f), 1f), (Phone("4_p", "p", 0.095f), 1f)], 140); Assert.All(SitePoints(script, "w_0_b"), v => Assert.Equal(0f, v)); - Assert.All(SitePoints(script, "w_4_p"), v => Assert.Equal(0f, v)); - Assert.All(SitePoints(script, "w_2_t"), v => Assert.True(v > 0.8f)); + Assert.All(SitePoints(script, "w_4_p").Skip(1), v => Assert.Equal(0f, v)); + // after the 30 ms boundary ramp from the previous plosive's place (the first point is that place) + Assert.All(SitePoints(script, "w_2_t").Skip(1), v => Assert.True(v > 0.8f)); } [Fact] @@ -120,11 +122,13 @@ public sealed class PlaceTableTests(ITestOutputHelper output) .Single(s => s.Name.StartsWith("w_1_c_constriction_diameter", StringComparison.Ordinal)).Points.Select(p => p.Value).ToArray(); var t = PatchScript.Parse(Word("t", "voiceless_alveolar_plosive")).ControlSplines .Single(s => s.Name.StartsWith("w_1_c_constriction_diameter", StringComparison.Ordinal)).Points; - Assert.Equal(0f, t[0].Value); + // lead-in (the vowel's open 1), arrival, closure hold, end: shut from the arrival to the hold, and the hold ends StopReleaseSeconds before the stop does + Assert.Equal(1f, t[0].Value); Assert.Equal(0f, t[1].Value); - Assert.Equal(0.65f, (t[1].TimeSeconds - 0.18f) / 0.095f, 3); + Assert.Equal(0f, t[2].Value); + Assert.Equal(1 - 0.012f / 0.095f, (t[2].TimeSeconds - 0.18f) / 0.095f, 3); var b = Diameter(Word("b")); - Assert.True(b[0] > 0 && Math.Abs(b[0] - b[1]) < 1e-6f, "the lip-sealed stop keeps the 0.03 aperture spline (its source text is pinned)"); + Assert.True(b[1] > 0 && Math.Abs(b[1] - b[2]) < 1e-6f, "the lip-sealed stop keeps the 0.03 aperture spline (its source text is pinned)"); } [Fact] diff --git a/tests/AquaSynth.Dsl.Tests/WeksaPhonesTests.cs b/tests/AquaSynth.Dsl.Tests/WeksaPhonesTests.cs index 3f0994f..02e7ccb 100644 --- a/tests/AquaSynth.Dsl.Tests/WeksaPhonesTests.cs +++ b/tests/AquaSynth.Dsl.Tests/WeksaPhonesTests.cs @@ -148,10 +148,10 @@ public sealed class WeksaPhonesTests Assert.Equal([WeksaWordPlan.ConsonantSeconds, WeksaWordPlan.VowelSeconds * WeksaWordPlan.CueFor(WeksaStress.Primary).Duration, WeksaWordPlan.ConsonantSeconds, WeksaWordPlan.ConsonantSeconds, WeksaWordPlan.VowelSeconds], plan.Phones.Select(p => p.Target.DurationSeconds)); var patch = PatchScript.Parse(IpaGestureExperiment.BuildWordScript(plan.Phones.ToArray(), 140)); - var ih = patch.ControlSplines.Where(s => s.Name.StartsWith("x_1_ɪ_vowel_", StringComparison.Ordinal)).ToDictionary(s => s.SurfacePath, s => s.Points[0].Value); + var ih = patch.ControlSplines.Where(s => s.Name.StartsWith("x_1_ɪ_vowel_", StringComparison.Ordinal)).ToDictionary(s => s.SurfacePath, s => s.Points[^1].Value); Assert.Equal(1f, ih["/vocal/areas/0/area/vowel_ih"]); Assert.Equal(0f, ih["/vocal/areas/0/area/vowel_i"]); - var oo = patch.ControlSplines.Where(s => s.Name.StartsWith("x_4_ʊ_vowel_", StringComparison.Ordinal)).ToDictionary(s => s.SurfacePath, s => s.Points[0].Value); + var oo = patch.ControlSplines.Where(s => s.Name.StartsWith("x_4_ʊ_vowel_", StringComparison.Ordinal)).ToDictionary(s => s.SurfacePath, s => s.Points[^1].Value); Assert.Equal(1f, oo["/vocal/areas/0/area/vowel_oo_short"]); Assert.Equal(0f, oo["/vocal/areas/0/area/vowel_u"]); } @@ -190,7 +190,7 @@ public sealed class WeksaPhonesTests var none = patch(WeksaStress.None); var primary = patch(WeksaStress.Primary); float First(SynthPatch p, string prefix, string surface) => - p.ControlSplines.Single(sp => sp.Name.StartsWith(prefix, StringComparison.Ordinal) && sp.SurfacePath == surface).Points[0].Value; + p.ControlSplines.Single(sp => sp.Name.StartsWith(prefix, StringComparison.Ordinal) && sp.SurfacePath == surface).Points[^1].Value; // pitch_ratio surface range 0.5..2: normalized (1.06 - .5) / 1.5; unstressed holds 1 -> (1 - .5) / 1.5. Assert.Equal((1.06f - .5f) / 1.5f, First(primary, "w_1_i_source_pitch", "/vocal/sources/0/pitch_ratio"), 4); diff --git a/tools/formant-check/ear_metrics.py b/tools/formant-check/ear_metrics.py new file mode 100644 index 0000000..bbaa65f --- /dev/null +++ b/tools/formant-check/ear_metrics.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python3 +"""What the formant numbers do not say. Measures a render for the faults Meta heard in tract-weak-spots-1 (2026-11-13) while every +formant matched its target; it does not listen, and a pass here is not a verdict (the listening page is). + ear_metrics.py FILE.wav [--f0 140] [--steady A B] [--json] + +click_ratio largest pitch-period-window peak over the median window peak. A voiced word with no transient is near 1; the pre-fix + nibu (a phone boundary stepping an area) was 3.54 with its window at the /b/ closure (0.271 s); after, 1.76 (a vowel's own pulses). +step_db largest single-sample step, in dB over the median sample step of the voiced part. A cell area that jumps is one sample wide. +bandwidths LPC pole bandwidths (Hz) of the steady part, F1..F3 as (Hz, bandwidth). Natural vowels run about 40-100 Hz at F1, 50-120 at + F2, 80-200 at F3 (Hawks & Miller 1995, Fant 1972); a lossless tube rings narrower, which reads as reedy. +hnr_db harmonics-to-noise ratio of the steady part by autocorrelation at the pitch lag. +hf_db energy above 4 kHz re the total, dB. +""" +import sys, wave, json, argparse +import numpy as np + + +def wav(path): + with wave.open(path) as w: + return np.frombuffer(w.readframes(w.getnframes()), dtype=" peaks.max() * 0.02] + if len(voiced) < 4: + return 0.0, 0.0 + at = int(np.argmax(peaks)) * (p // 2) / sr + return float(peaks.max() / np.median(voiced)), at + + +def step_db(x): + d = np.abs(np.diff(x)) + live = d[d > d.max() * 1e-3] + return float(20 * np.log10(d.max() / max(np.median(live), 1e-12))) if len(live) else 0.0 + + +def autocorr(s, n=None): + """Autocorrelation at lags 0..n-1 by FFT (np.correlate is quadratic).""" + n = n or len(s) + f = np.fft.rfft(s, 2 * len(s)) + return np.fft.irfft(f * np.conj(f))[:n] + + +def lpc(s, o): + s = s * np.hamming(len(s)) + r = autocorr(s, o + 1) + R = np.array([[r[abs(i - j)] for j in range(o)] for i in range(o)]) + a = np.linalg.solve(R + 1e-9 * r[0] * np.eye(o), r[1:o + 1]) + return np.concatenate([[1], -a]) + + +def bandwidths(y, sr, order=14): + dec = max(1, int(round(sr / 10000))) + k = np.hanning(4 * dec + 1) + k /= k.sum() + z = np.convolve(y - y.mean(), k, "same")[::dec] + fs = sr / dec + z = np.append(z[0], z[1:] - 0.97 * z[:-1]) + rt = np.roots(lpc(z, order)) + rt = rt[np.imag(rt) > 0.001] + fq = np.angle(rt) * fs / (2 * np.pi) + bw = -np.log(np.abs(rt)) * fs / np.pi + # a formant is a narrow pole; broad poles (> 400 Hz) are the spectral tilt the all-pole fit spends order on + return [(int(f), int(b)) for f, b in sorted(zip(fq, bw)) if 150 < f < 4500 and b < 400][:3] + + +def hnr_db(y, sr, f0): + y = y - y.mean() + ac = autocorr(y) + ac /= ac[0] + lo, hi = int(sr / (f0 * 1.3)), int(sr / (f0 * 0.75)) + m = float(ac[lo:hi].max()) + return 10 * np.log10(max(m, 1e-6) / max(1 - m, 1e-6)) + + +def measure(path, f0=140.0, steady=None): + x, sr = wav(path) + a, b = steady if steady else (len(x) / sr * 0.35, len(x) / sr * 0.85) + y = x[int(a * sr):int(b * sr)] + sp = np.abs(np.fft.rfft((y - y.mean()) * np.hanning(len(y)))) + fr = np.fft.rfftfreq(len(y), 1 / sr) + cr, at = click_ratio(x, sr, f0) + return { + "file": path.split("/")[-1], "click_ratio": round(cr, 2), "click_at_s": round(at, 4), "step_db": round(step_db(x), 1), + "bandwidths": bandwidths(y, sr), "hnr_db": round(hnr_db(y, sr, f0), 1), + "hf_db": round(float(10 * np.log10(max((sp[fr > 4000] ** 2).sum(), 1e-20) / (sp ** 2).sum())), 1), + } + + +if __name__ == "__main__": + ap = argparse.ArgumentParser() + ap.add_argument("files", nargs="+") + ap.add_argument("--f0", type=float, default=140.0) + ap.add_argument("--steady", nargs=2, type=float) + ap.add_argument("--json", action="store_true") + a = ap.parse_args() + rows = [measure(f, a.f0, a.steady) for f in a.files] + if a.json: + print(json.dumps(rows, indent=1)) + else: + for r in rows: + print(f"{r['file']:20s} click {r['click_ratio']:5.2f} at {r['click_at_s']:.3f}s step {r['step_db']:5.1f} dB hnr {r['hnr_db']:5.1f} hf {r['hf_db']:6.1f} F(Hz,bw) {r['bandwidths']}") diff --git a/tools/formant-check/phone_probe.py b/tools/formant-check/phone_probe.py new file mode 100644 index 0000000..ddd6a75 --- /dev/null +++ b/tools/formant-check/phone_probe.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +"""A machine ear for the tract renders: what phone string a speech recogniser reads out of a clip. A PROXY for 'what was heard', never a +verdict: it is trained on natural speech and reads the vowels of this tract poorly (every isolated vowel came back as /i/), so use it +for the events it separates well (a burst read as /v/ against /b/, a nasal present or missing, a consonant that is only a click). +It reproduced three of Meta's four first listening reports on tract-weak-spots-1 before any fix: ba with burst -> 'v ɑ' (she heard +'fah then bah'), ana -> 'v ɑ m ɑ' (a basketball buzzer, no articulation), nibu -> 'i b u' (both consonants clicks, the /n/ missing). + phone_probe.py CLIP.wav... +Needs torch, transformers, scipy and the HuggingFace model facebook/wav2vec2-lv-60-espeak-cv-ft (about 1.2 GB, downloaded once into +HF_HOME). The CTC decode reads vocab.json directly, so the phonemizer library is not needed. +""" +import sys, wave, json +import numpy as np +import torch +from scipy.signal import resample_poly +from transformers import Wav2Vec2ForCTC +from huggingface_hub import hf_hub_download + +MODEL = "facebook/wav2vec2-lv-60-espeak-cv-ft" + + +def phones(model, vocab, path): + with wave.open(path) as w: + sr = w.getframerate() + x = np.frombuffer(w.readframes(w.getnframes()), dtype="