the ultimate vocal synthesizer - sing, speak, beatbox, and more
Rust
Hill climb 23: /v z/'s folds part about as wide as the constriction, so the oral pressure rises and the voice weakens; /ð/ held back (its duration, "The" heard as "with a")
Jameson Hodgee794fd26d127
diff --git a/crates/chimera/src/phonetics/planner.rs b/crates/chimera/src/phonetics/planner.rsindex d149800..d7cd4c2 100644--- a/crates/chimera/src/phonetics/planner.rs+++ b/crates/chimera/src/phonetics/planner.rs@@ -21,6 +21,17 @@ pub const EXHALE_LABEL: &str = "exhale";/// when a sung phrase's breath reaches full drive, after the plan start (its first segment starts at 0.06)const BREATH_SUNG_AT: f64 = 0.06;+/// How far a voiced fricative's folds part (cm², scaled with the body in the voice). Frication and+/// voicing share the lung pressure, which takes a glottis about as wide as the constriction+/// (Stevens 1971; Elie & Laprie's "regime B"). Here that is a mean glottal area of about 0.13 cm²,+/// through constrictions of 0.10-0.18. The pressure behind the constriction then rises and the+/// voicing weakens by itself, most in /z/, whose constriction is the narrowest. 0.12-0.14 match the+/// TSP speakers' voicing better; female /z/ can't take them yet (hill-climb log, experiment 23).+const VOICED_FRICATIVE_OPENING: f64 = 0.09;+/// /ð/ keeps a small opening for now: with the wider one its first-word voice weakens, MFA reads the+/// constriction's 70-110 ms where speakers' /ð/ reads 40-50, and Whisper hears "The" as "with a".+const DH_OPENING: f64 = 0.035;+const VOWEL_KEYS: [ArticKey; 9] = [ArticKey::TbX, ArticKey::TbY, ArticKey::Jaw, ArticKey::LipAp, ArticKey::LipProt, ArticKey::LipWidth, ArticKey::Root, ArticKey::Larynx, ArticKey::TtCurl];/// One calibrated vowel of `vowelTargets.generated.json`.@@ -324,7 +335,10 @@ pub fn plan_utterance(input: &[Segment], o: &PlanOptions) -> Plan {gestures.push(Gesture::new(t0 - 0.015, t1 + 0.005, 0.03, 0.03, 6.0, one(ControlKey::ABDUCTION, 0.3)).label("voiceless"));}} else if def.manner == Manner::Fricative {- gestures.push(Gesture::new(t0, t1, 0.03, 0.03, 3.0, one(ControlKey::ABDUCTION, 0.035)).label("voiced frication"));+ // the folds start to part when a voiceless fricative's do, and close as the constriction+ // opens (about 20 ms after t1, for both)+ let opening = if def.ipa == "ð" { DH_OPENING } else { VOICED_FRICATIVE_OPENING };+ gestures.push(Gesture::new(t0 - 0.015, t1, 0.03, 0.03, 3.0, one(ControlKey::ABDUCTION, opening)).label("voiced frication"));}}let open_end = o.open_end == Some(true);diff --git a/crates/chimera/tests/voiced_fricatives.rs b/crates/chimera/tests/voiced_fricatives.rsnew file mode 100644index 0000000..6127bd6--- /dev/null+++ b/crates/chimera/tests/voiced_fricatives.rs@@ -0,0 +1,50 @@+//! A voiced fricative divides the lung pressure between the folds and the constriction, so its voicing+//! is far weaker than a vowel's (experiment 23). With the folds nearly as closed as in a vowel, the oral+//! pressure stayed near 1 cmH2O and the voice under /v z/ was 10-18 dB above the real speakers' (their+//! band below 1.2 kHz: /v/ -23 dB re their stressed vowels, /z/ -33 to -37).+use chimera::anatomy::human::{BODY_FEMALE, BODY_MALE};+use chimera::phonetics::ipa::tokenize_ipa;+use chimera::phonetics::planner::{PlanOptions, plan_utterance};+use chimera::voice::human_voice::{HumanVoice, SourcePatch};++const FS: f64 = 48000.0;++/// Power below about 1 kHz (two one-pole low-passes), per sample, for the samples from `a` to `b`.+fn low_band(x: &[f32], a: f64, b: f64) -> f64 {+ let k = 1.0 - (-2.0 * std::f64::consts::PI * 1000.0 / FS).exp();+ let (mut y1, mut y2, mut sum, mut n) = (0.0f64, 0.0f64, 1e-20f64, 0.0f64);+ for (i, s) in x.iter().enumerate() {+ y1 += k * (f64::from(*s) - y1);+ y2 += k * (y1 - y2);+ let t = i as f64 / FS;+ if t >= a && t < b {+ sum += y2 * y2;+ n += 1.0;+ }+ }+ sum / n+}++#[test]+fn the_voice_weakens_behind_a_voiced_fricatives_constriction() {+ for (body, name, f0) in [(BODY_MALE, "male", 112.0), (BODY_FEMALE, "female", 205.0)] {+ for (c, limit) in [("z", -13.0), ("v", -6.5)] {+ let plan = plan_utterance(&tokenize_ipa(&format!("ˈɑ{c}ɑ")), &PlanOptions { body: name.into(), t0: 0.05, f0: Some(f0), ..Default::default() });+ let span = plan.segments.iter().find(|s| s.ipa == c).unwrap();+ let vowel = &plan.segments[0];+ let mut v = HumanVoice::new(FS, body, 2);+ v.set_source(&SourcePatch::f0(f0));+ v.schedule(&plan.gestures);+ let mut out = vec![0.0f32; (FS * (plan.end + 0.3)).round() as usize];+ for chunk in out.chunks_mut(128) {+ v.render(chunk);+ }+ let quarter = 0.25 * (span.t1 - span.t0);+ let voice = low_band(&out, span.t0 + quarter, span.t1 - quarter);+ let reference = low_band(&out, vowel.t0 + 0.03, vowel.t1 - 0.03);+ let level = 10.0 * (voice / reference).log10();+ println!("{name} /{c}/: voice {level:.1} dB re the vowel");+ assert!(level < limit, "{name} /{c}/: voice {level:.1} dB re the vowel, limit {limit}");+ }+ }+}