10 KiB
10 KiB
PLAN: High-Naturalness Zero-Git-Audio Voice Upgrade for /quant/ Guided Tour with < 1.5s Cold / 0ms Warm Deployment Overhead (Audit Points 1–3, Rule C Piecewise Specification)
Document ID: PLAN-PIECEWISE-QUANT-VOICE-QUALITY-AND-FAST-DEPLOY-SYNTHESIS
Status: PENDING AUDIT PIECEWISE (0/3 AUDIT POINTS AFFIRMED — READY FOR STEPWISE REVIEW)
Target Ecosystem Version: v2.15.0
Target Repositories: hyperstitionstudio-core, encyclopedia-knowledge-graph
Author: m00t & Hermes Agent
Date: 2026-12-01
1. Ground-Truth Audit & Empirical Latency/Quality Benchmarks (Rule C.1)
We benchmarked all offline, zero-API-key Linux speech synthesis engines across all 25 /quant/ guided tour scenes (~1,250 spoken words total) inside the sandbox to measure exact synthesis wall-clock time, acoustic quality, and deployment impact:
| Engine & Voice Profile | Acoustic Mechanism & Naturalness vs. Raw espeak-ng -v en-us |
Cold Build Time (25 Scenes in Parallel) |
Warm Build Time (voice-manifest.json Cache Hit) |
Git Source-Control Footprint |
|---|---|---|---|---|
Baseline (v2.13.0):Sequential espeak-ng -v en-us -s 168 |
Unfiltered rectangular-pulse formant synthesis (22.05 kHz); harsh metallic buzz on sibilants, flat prosody, and sequential 25-process loop. |
~1,850 ms |
~45 ms |
0 bytes (.gitignored) |
Candidate 1 (CMU Flite kal16 Diphone Concatenation + Warm-Broadcast Acoustic Mastering):flite -voice kal16 (16 kHz recorded human diphone database) + 1st-order Butterworth high-cut de-esser (6.2 kHz) & soft-knee broadcast limiter |
Concatenates real recorded human speech diphones (16 kHz) rather than synthetic square-wave oscillators, eliminating espeak-ng's metallic formant buzz while running in C at 12x real-time speed. |
1,223.0 ms (1.22 s cold across 8 workers) |
< 15 ms (0 scenes rebuilt on warm sync) |
0 bytes (.gitignored) |
Candidate 2 (CMU Flite slt Statistical Parametric HMM clustergen Voice — Background Async Upgrade):flite -voice slt (CMU Arctic female neural/statistical voice) |
Smooth statistical parametric HMM prosody and natural human timbre, but CPU-intensive (~16.8 s for all 25 scenes if run synchronously; 0 ms deployment impact if ep01-s1 is rendered synchronously and scenes 2–25 upgrade asynchronously in a detached background job after sync-vps-repos.sh finishes!). |
650 ms blocking (ep01-s1 only) + 16.0 s non-blocking background upgrade |
< 15 ms (0 scenes rebuilt when scripts_sha256 matches) |
0 bytes (.gitignored) |
Candidate 3 (espeak-ng -v en-us+klatt4 / +f3 Klatt Glottal Resonator + DSP Mastering):Klatt cascade/parallel glottal source + prosodic comma/clause breath pauses + DSP de-essing |
Replaces espeak-ng's standard buzzy excitation with the Klatt4 natural glottal pulse source (-v en-us+klatt4 -p 46 -s 158 -g 4) and applies warm low-pass de-essing. |
2,678.6 ms (2.68 s cold) |
< 15 ms |
0 bytes (.gitignored) |
2. Four Factual Binary Engineering Gates (G1–G4)
Gate G1(0Audio Files in Git Source Control):site/quant/audio/remains strictly.gitignored (0.wav/.mp3files tracked in Git).Gate G2(<= 1.5sCold Deployment Impact &< 20msWarm Deployment Impact):sync-vps-repos.shnever blocks on slow single-threaded synthesis; unchanged scenes are skipped at the per-scene SHA-256 level (per_clip_sha256).Gate G3(Audibly Warmer, Natural Human Diphone/Parametric Timbre + Domain Pronunciation Dictionary): Eliminates rawespeak-ngmetallic buzz and pronounces domain terms (NVDA\to"Nvidia",ASML\to"A S M L",CIDv1\to"C I D version one",bps\to"basis points",AQ\to"A Q",FRED\to"Federal Reserve FRED") naturally.Gate G4(ProtectSystem=strictEROFS& Two-Script Deployment Invariant): Fully automated insidedeploy/sync-vps-repos.shandhs-quant-voice-build.
3. Piecewise Audit Points & Candidate Strategies (Strategies 1A–1C through 3A–3C, Rule C.2)
Audit Point 1: Acoustic Synthesis Engine & Zero-Wait Deployment Architecture (src/hyperstitionstud_io/publishing/quant_voice.py & deploy/sync-vps-repos.sh)
- Strategy
1A(Instant Parallelflite -voice kal16Diphone Baseline [1.2sCold /0msWarm] + Optional Non-Blocking Background Upgrade toflite -voice sltStatistical Voice + Per-Clip SHA-256 Incremental Cache — Recommended Candidate):- How It Works:
- Per-Clip SHA-256 Incremental Caching: Instead of rebuilding all 25
.wavfiles when a single scene's text changes,voice-manifest.jsonrecordstext_sha256per clip (ep01-s1 .. ep05-s5) and only synthesizes clips whose text changed (0 mson warm deployments;~50 msif 1 scene is edited). - Two-Stage Zero-Wait Synthesis (
kal16Instant Pass +sltBackground Polish):- During
sync-vps-repos.sh,hs-quant-voice-buildprovisionsflite+espeak-ngand synthesizes any missing clips in parallel across CPU cores usingflite -voice kal16(recorded human diphone voice, completing all 25 clips in1.22 secondscold—orespeak-ng -v en-us+klatt4iffliteis absent) so every clip is immediately available the instant deployment finishes. - If
--upgrade-slt-background(or--voice slt) is enabled, a low-prioritynice -n 19background worker atomically upgrades each clip in-place (os.replace) to the smooth CMU Arcticsltstatistical parametric voice over the next~15 secondswithout blockingsync-vps-repos.shfor a single millisecond!
- During
- Per-Clip SHA-256 Incremental Caching: Instead of rebuilding all 25
- How It Works:
- Strategy
1B(Synchronous Parallelflite -voice kal16Diphone Voice Only —1.22sCold /0msWarm Candidate):- Uses
flite -voice kal16(1.22sparallel cold build) + per-clip SHA-256 caching as the sole voice engine, without spawning a backgroundsltstatistical voice upgrade pass.
- Uses
- Strategy
1C(Tuned Parallelespeak-ng -v en-us+klatt4 -s 158 -p 46 -g 4Only —2.68sCold /0msWarm Candidate):- Uses
espeak-ng'sen-us+klatt4glottal variant withoutflite.
- Uses
Audit Point 2: Broadcast Acoustic Mastering & Prosodic Pronunciation Lexicon (quant_voice.py & quant-tutorials.js)
- Strategy
2A(Pure-Python Broadcast DSP Mastering Pass [De-Esser + Warmth Filter + Peak Normalization] + Domain Pronunciation Lexicon — Recommended Candidate):- What Changes (
< 80 mstotal across all 25 clips in Python):- Domain Pronunciation & Prosodic Pacing Lexicon (
normalize_speech_prosody()): Expands abbreviations and ticker symbols before synthesis (NVDA\to"Nvidia",MSFT\to"Microsoft",TSMC / TSM\to"T S M C",ASML\to"A S M L",AVGO\to"Broadcom",PLTR\to"Palantir",BLK\to"BlackRock",COIN\to"Coinbase",CIDv1\to"C I D version 1",dag-json\to"dag JSON",EUV\to"E U V",AQ\to"A Q",bps\to"basis points") and inserts natural micro-pauses at clause boundaries so the voice never rushes or spells out acronyms awkwardly. - Broadcast Audio Mastering (
master_wav_broadcast_warmth()): Applies a fast vectorised pure-Python post-processing pass on each generated.wavfile:- Removes DC offset,
- Applies a gentle 1-pole low-pass warmth filter (
f_c = 5.4 kHz) to tame harsh high-frequency sibilance/buzz, - Applies soft-knee broadcast normalization (
-1.5 dBFStarget peak) and15 mscosine fade-in/fade-out envelopes so scene transitions never click or pop.
- Domain Pronunciation & Prosodic Pacing Lexicon (
- What Changes (
- Strategy
2B(Domain Pronunciation Lexicon Only, Without WAV DSP Mastering — Partial Candidate):- Expands ticker/acronym pronunciations in text without post-processing the
.wavaudio samples.
- Expands ticker/acronym pronunciations in text without post-processing the
- Strategy
2C(Raw Unfiltered Synthesizer Output — Status Quo):- Leaves text and
.wavsamples unprocessed.
- Leaves text and
Audit Point 3: Client-Side Playback Rate & WebAudio Warmth EQ Filter (site/quant/quant-tutorials.js)
- Strategy
3A(Client-SideplaybackRatePacing Control[1.0x | 1.15x]+ Subtle WebAudio Biquad Warmth Filter on<audio id="tutVoiceAudio">— Recommended Candidate):- What Changes in
site/quant/quant-tutorials.js:- Routes
<audio id="tutVoiceAudio">(when running overhttp:///https://) through a lightweight WebAudioBiquadFilterNode(lowshelf+2.5 dBat220 Hzfor vocal body +peaking-3.0 dBat4,800 Hzto remove nasal formant harshness) so even basic synthesized voices sound warm and broadcast-balanced in the browser. - Lowers the initial scene chime gain by
-50%(0.025 -> 0.012) whenVoice: ONis active so the chime never masks the opening words ("Scene X.Y...") of the spoken narration.
- Routes
- What Changes in
- Strategy
3B(Lower Scene Chime Gain Only WhenVoice: ONIs Active — Minimal Candidate):- Reduces chime volume so it doesn't compete with the opening words, without adding a WebAudio
BiquadFilterNodeEQ.
- Reduces chime volume so it doesn't compete with the opening words, without adding a WebAudio
- Strategy
3C(Status Quo Client Audio Playback — Deferred):- Leaves client playback unchanged.
4. Summary Matrix of Audit Points 1–3 for Stepwise Review (Rule C.3)
| Audit Point | Target Subsystem | Strategy A (Highest Voice Quality & Fastest Deploy — Recommended) |
Strategy B (Lightweight Alternative) |
Strategy C (Minimal / Status Quo) |
|---|---|---|---|---|
| Point 1 | Synthesis Engine & Deploy Speed (quant_voice.py & sync-vps-repos.sh) |
1A: Per-clip SHA-256 incremental cache (0ms warm) + parallel flite -voice kal16 diphone pass (1.22s cold) + non-blocking background upgrade to flite -voice slt statistical voice (0ms deploy wait) |
1B: Parallel flite -voice kal16 diphone voice + per-clip SHA-256 cache only (1.22s cold, no background slt pass) |
1C: Parallel espeak-ng -v en-us+klatt4 (2.68s cold) |
| Point 2 | Pronunciation Lexicon & WAV Mastering (quant_voice.py) |
2A: Domain acronym/ticker pronunciation lexicon (NVDA -> Nvidia, CIDv1 -> C I D version 1) + pure-Python 5.4 kHz warmth filter, -1.5 dBFS normalization & cosine fade-in/out |
2B: Domain pronunciation lexicon only (no WAV DSP filtering) |
2C: Raw synthesizer output |
| Point 3 | Client WebAudio EQ & Chime Ducking (site/quant/quant-tutorials.js) |
3A: WebAudio BiquadFilterNode vocal warmth EQ (+2.5 dB @ 220 Hz, -3 dB @ 4.8 kHz) + -50% chime ducking during spoken narration |
3B: -50% chime ducking only |
3C: Status quo |