Add native speech synthesis and voice-imitation faculty
El SDK CI - dev / build-and-test (pull_request) Successful in 6m28s
El SDK CI - dev / build-and-test (pull_request) Successful in 6m28s
speech.el: formant/glottal integer DSP synthesis + voice-analyze-by-
imitation. voice-profile.el / voice-ingest.el: voice-profile plumbing.
accent.el: British-RP as an ingested transform-geometry (explicitly marked
provisional/citation-pending by its own comments). organ-read.el:
engram read-through for the speech organ. Includes demo/test drivers and
non-personal reference data (British-RP phonetics/lexicon derived data,
a public-domain LibriVox RP reference recording).
Deliberately excludes elp/data/live/ (raw recorded voice + face-photo
samples of the repo owner) and the will-*.{json,psv} derived voiceprint
files — personal biometric data that shouldn't be committed to a shared
repo without an explicit decision from the owner. Also excludes this
worktree's elp/src/surface-profile.el, which diverges from the copy in
other worktrees (agent-aaf04b0a9714c4070, main) — needs manual
reconciliation before landing, left out here to avoid silently picking a
version.
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
// speech-accent-demo.el - PROOF: Neuron speaks with a BRITISH accent, where the
|
||||
// accent is a TRANSFORM composed onto the voice (voice (+) accent, separable),
|
||||
// INGESTED as geometry (not a table). Same voice, accent toggled on/off = RP/GA.
|
||||
|
||||
fn main() {
|
||||
let outdir: String = "/Users/will/Development/neuron-technologies/foundation/el/.claude/worktrees/agent-acc02900ef4ade35e/elp/tests/examples/out/"
|
||||
|
||||
// LEARN: base phonetics + lexicon + the British-RP accent transform, all as
|
||||
// ingested geometry (source -> manifold -> engram).
|
||||
let pmap: [String] = ingest_phonetics("elp/data/phonetics.psv")
|
||||
let lmap: [String] = ingest_lexicon("elp/data/lexicon.psv")
|
||||
let amap: [String] = ingest_accent("elp/data/british-accent.psv")
|
||||
println("[learn] phonemes=" + int_to_str(native_list_len(pmap) / 2) + " words=" + int_to_str(native_list_len(lmap) / 2) + " accent_targets=" + int_to_str(native_list_len(amap) / 2))
|
||||
|
||||
let neuron: [String] = voice_neuron()
|
||||
let noaccent: [String] = native_list_empty()
|
||||
|
||||
// -- Sentence 1: "I am Neuron." from meaning ----------------------------
|
||||
let fr1: [String] = sem_frame("describe", "I", "Neuron", "")
|
||||
let t1: String = sem_realize(fr1)
|
||||
let c1: [String] = text_phonemes(lmap, t1)
|
||||
println("[s1] " + t1 + " :: " + list_join(c1, " "))
|
||||
|
||||
// separability: SAME voice, accent OFF (GA) vs ON (RP)
|
||||
let ga: [Int] = synth_codes_accent(c1, neuron, pmap, noaccent)
|
||||
let okga: Bool = write_wav(ga, 16000, outdir + "ga-neuron.wav")
|
||||
let br1: [Int] = synth_codes_accent(c1, neuron, pmap, amap)
|
||||
let okb1: Bool = write_wav(br1, 16000, outdir + "british-neuron.wav")
|
||||
|
||||
// -- Sentence 2: showcases NON-RHOTICITY --------------------------------
|
||||
let fr2: [String] = sem_frame("describe", "I", "here", "")
|
||||
let t2: String = sem_realize(fr2)
|
||||
let c2: [String] = text_phonemes(lmap, t2)
|
||||
let c2rp: [String] = apply_rhoticity(c2, pmap)
|
||||
println("[s2] " + t2 + " :: GA=" + list_join(c2, " ") + " RP=" + list_join(c2rp, " "))
|
||||
let br2: [Int] = synth_codes_accent(c2, neuron, pmap, amap)
|
||||
let okb2: Bool = write_wav(br2, 16000, outdir + "british-2.wav")
|
||||
|
||||
// show an RP override read straight from the accent geometry
|
||||
let ovAA: [Int] = accent_formants(amap, "AA")
|
||||
if native_list_len(ovAA) >= 3 {
|
||||
println("[accent-geometry] AA(LOT) RP f1=" + int_to_str(native_list_get(ovAA, 0)) + " f2=" + int_to_str(native_list_get(ovAA, 1)) + " (base GA 730/1090) [PROVISIONAL]")
|
||||
}
|
||||
println("[done] ga-neuron=" + bool_to_str(okga) + " british-neuron=" + bool_to_str(okb1) + " british-2=" + bool_to_str(okb2))
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// speech-demo.el - PROOF: Neuron speaks from MEANING, rendered through INGESTED
|
||||
// phonetic geometry, own-core, plus voice-by-IMITATION. Built by concatenating
|
||||
// the elp realizer + voice-profile + speech-ingest + speech, then this main.
|
||||
//
|
||||
// LEARN : ingest acoustic-phonetics + lexicon SOURCES -> phoneme manifold in
|
||||
// the engram (source -> manifold -> merge).
|
||||
// MEANING : sem_frame("describe","I","Neuron","") -> sem_realize -> "I am Neuron."
|
||||
// PHONES : words -> phoneme codes, READ from the ingested lexicon geometry.
|
||||
// RENDER : superpose formant resonances (read from engram) over a glottal
|
||||
// source -> own-core PCM/WAV, in Neuron's own voice.
|
||||
// IMITATE : HEAR a short sample of a different voice -> extract its signature
|
||||
// by ear (autocorrelation pitch + integer-DFT formant) -> render new
|
||||
// speech in that voice. An impression, not a corpus.
|
||||
|
||||
fn speak_report(tag: String, codes: [String], voice: [String], pmap: [String], path: String) -> [Int] {
|
||||
let s: [Int] = synth_codes(codes, voice, pmap)
|
||||
let ok: Bool = write_wav(s, 16000, path)
|
||||
println(tag + " samples=" + int_to_str(native_list_len(s)) + " ok=" + bool_to_str(ok) + " -> " + path)
|
||||
return s
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let outdir: String = "/private/tmp/claude-501/-Users-will/6531446d-bc27-4095-930b-e04777c3db4f/scratchpad/"
|
||||
|
||||
// -- LEARN: ingest the speech primitives as geometry --------------------
|
||||
let pmap: [String] = ingest_phonetics("elp/data/phonetics.psv")
|
||||
let lmap: [String] = ingest_lexicon("elp/data/lexicon.psv")
|
||||
let saved: Bool = engram_save(outdir + "phoneme-manifold.json")
|
||||
println("[learn] phonemes=" + int_to_str(native_list_len(pmap) / 2) + " words=" + int_to_str(native_list_len(lmap) / 2) + " manifold_saved=" + bool_to_str(saved))
|
||||
|
||||
// sanity: show that AA's formants came from ingested geometry, not code
|
||||
let aa: [Int] = phon_geo(pmap, "AA")
|
||||
let aaF1: Int = native_list_get(aa, 0)
|
||||
let aaF2: Int = native_list_get(aa, 1)
|
||||
println("[read-geometry] AA F1=" + int_to_str(aaF1) + " F2=" + int_to_str(aaF2) + " (parsed from engram node)")
|
||||
|
||||
// -- MEANING -> WORDS via the realizer's language faculty ----------------
|
||||
let frame: [String] = sem_frame("describe", "I", "Neuron", "")
|
||||
let text: String = sem_realize(frame)
|
||||
println("[meaning->text] " + text)
|
||||
|
||||
// -- WORDS -> PHONEMES (read from ingested lexicon geometry) --------------
|
||||
let codes: [String] = text_phonemes(lmap, text)
|
||||
println("[phonemes] " + list_join(codes, " "))
|
||||
|
||||
// -- RENDER in Neuron's own voice ----------------------------------------
|
||||
let neuron: [String] = voice_neuron()
|
||||
let s1: [Int] = speak_report("[speak neuron]", codes, neuron, pmap, outdir + "neuron.wav")
|
||||
|
||||
// -- IMITATION: hear a distinct voice, recover its signature, re-render ---
|
||||
let vA: [String] = voice_target_a()
|
||||
let hcodes: [String] = native_list_empty()
|
||||
hcodes = native_list_append(hcodes, "SIL")
|
||||
let z: Int = 0
|
||||
while z < 6 {
|
||||
hcodes = native_list_append(hcodes, "AA")
|
||||
z = z + 1
|
||||
}
|
||||
hcodes = native_list_append(hcodes, "SIL")
|
||||
let heard: [Int] = synth_codes(hcodes, vA, pmap)
|
||||
let okh: Bool = write_wav(heard, 16000, outdir + "heard.wav")
|
||||
|
||||
let vB: [String] = voice_analyze(heard, 16000)
|
||||
println("[imitate] heard ACTUAL f0=" + voice_get(vA, "f0") + " kf=" + voice_get(vA, "kf"))
|
||||
println("[imitate] heard RECOVERED f0=" + voice_get(vB, "f0") + " kf=" + voice_get(vB, "kf") + " (extracted by ear from PCM)")
|
||||
let s2: [Int] = speak_report("[speak imitation]", codes, vB, pmap, outdir + "imitation.wav")
|
||||
|
||||
println("[done] rendered from meaning + ingested geometry; imitation from a heard sample.")
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// speech-organ-demo.el - PROOF: the render now reads its phoneme + accent
|
||||
// GEOMETRY from the ingest ORGAN's saved engram files (engram_load +
|
||||
// engram_scan_nodes_json + cache), not a same-run hand-load. The British accent
|
||||
// is still a composed transform-geometry (voice (+) accent, separable). Numbers
|
||||
// come from the organ manifold; the .psv supplies only categorical vowel-class.
|
||||
|
||||
fn main() {
|
||||
let outdir: String = "/Users/will/Development/neuron-technologies/foundation/el/.claude/worktrees/agent-acc02900ef4ade35e/elp/tests/examples/out/"
|
||||
|
||||
// engram-independent caches from source (survive engram_load replacement)
|
||||
let vset: [String] = organ_vset("elp/data/phonetics.psv")
|
||||
let lmap: [String] = organ_lex("elp/data/lexicon.psv")
|
||||
// ORGAN read: phonetics FIRST (cache), THEN accent (engram_load replaces store)
|
||||
let pmap: [String] = organ_pmap("elp/data/phonetics-formants.engram.json")
|
||||
let amap: [String] = organ_amap("elp/data/british-accent.engram.json")
|
||||
println("[organ] phon_syms=" + int_to_str(native_list_len(pmap) / 2) + " accent_syms=" + int_to_str(native_list_len(amap) / 2) + " vowels=" + int_to_str(native_list_len(vset)) + " words=" + int_to_str(native_list_len(lmap) / 2))
|
||||
|
||||
// prove the numbers came from the organ node content
|
||||
let g: [Int] = phon_geo(pmap, "AA")
|
||||
println("[organ-read] phoneme AA f1=" + int_to_str(native_list_get(g, 0)) + " f2=" + int_to_str(native_list_get(g, 1)) + " f3=" + int_to_str(native_list_get(g, 2)) + " (P&B1952 MEASURED)")
|
||||
let ov: [Int] = accent_formants(amap, "AA")
|
||||
if native_list_len(ov) >= 3 {
|
||||
println("[organ-read] accent AA(LOT) f1=" + int_to_str(native_list_get(ov, 0)) + " f2=" + int_to_str(native_list_get(ov, 1)) + " (DERIVED RP, PROVISIONAL)")
|
||||
}
|
||||
println("[organ-read] non_rhotic=" + int_to_str(is_nonrhotic(amap)))
|
||||
|
||||
let neuron: [String] = voice_neuron()
|
||||
let noacc: [String] = native_list_empty()
|
||||
|
||||
// Sentence 1: "I am Neuron." from meaning; GA vs RP = separable toggle
|
||||
let t1: String = sem_realize(sem_frame("describe", "I", "Neuron", ""))
|
||||
let c1: [String] = text_phonemes(lmap, t1)
|
||||
println("[s1] " + t1 + " :: " + list_join(c1, " "))
|
||||
let ga: [Int] = synth_codes_accent(c1, neuron, pmap, noacc, vset)
|
||||
let okga: Bool = write_wav(ga, 16000, outdir + "ga-neuron-organ.wav")
|
||||
let br1: [Int] = synth_codes_accent(c1, neuron, pmap, amap, vset)
|
||||
let okb1: Bool = write_wav(br1, 16000, outdir + "british-neuron-organ.wav")
|
||||
|
||||
// Sentence 2: non-rhoticity showcase
|
||||
let t2: String = sem_realize(sem_frame("describe", "I", "here", ""))
|
||||
let c2: [String] = text_phonemes(lmap, t2)
|
||||
let c2rp: [String] = apply_rhoticity(c2, vset)
|
||||
println("[s2] " + t2 + " :: GA=" + list_join(c2, " ") + " RP=" + list_join(c2rp, " "))
|
||||
let br2: [Int] = synth_codes_accent(c2, neuron, pmap, amap, vset)
|
||||
let okb2: Bool = write_wav(br2, 16000, outdir + "british-2-organ.wav")
|
||||
|
||||
println("[done] ga-organ=" + bool_to_str(okga) + " british-organ=" + bool_to_str(okb1) + " british-2-organ=" + bool_to_str(okb2))
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// speech-voice-demo.el - LIVE VOICE LOOP (stand-in test). Capture -> voiceprint
|
||||
// -> reshape -> INGEST AS GEOMETRY -> read the target back FROM geometry -> the
|
||||
// EL projector renders a line reaching for that voice. Stand-in "Will" = the
|
||||
// voiceprint of imitation.wav. HONEST: pitch + coarse vocal-tract scale, NOT a clone.
|
||||
|
||||
fn main() {
|
||||
let outdir: String = "/Users/will/Development/neuron-technologies/foundation/el/.claude/worktrees/agent-acc02900ef4ade35e/elp/tests/examples/out/"
|
||||
let vp: String = "/private/tmp/claude-501/-Users-will/6531446d-bc27-4095-930b-e04777c3db4f/scratchpad/will-voiceprint.json"
|
||||
|
||||
// 1+2: reshape voiceprint JSON -> organ voice-signature source
|
||||
let sig0: [String] = native_list_empty()
|
||||
let sig: [Int] = reshape_voiceprint(vp, "elp/data/will-voice.json")
|
||||
// 3: ingest as geometry + engram_save a reloadable manifold file
|
||||
let ig: Int = ingest_voice(sig, "elp/data/will-voice.engram.json")
|
||||
// 4: READ the target back FROM geometry (engram_load + scan + filter)
|
||||
let g: [Int] = load_voice("elp/data/will-voice.engram.json")
|
||||
println("[voice-geometry] read from manifold: f0=" + int_to_str(native_list_get(g, 0)) + " f0_end=" + int_to_str(native_list_get(g, 1)) + " kf=" + int_to_str(native_list_get(g, 2)) + " f1=" + int_to_str(native_list_get(g, 3)) + " f2=" + int_to_str(native_list_get(g, 4)) + " f3=" + int_to_str(native_list_get(g, 5)) + " (measured, COARSE — not a clone)")
|
||||
|
||||
// phoneme geometry from the organ (loaded AFTER the voice sig is cached in EL)
|
||||
let pmap: [String] = organ_pmap("elp/data/phonetics-formants.engram.json")
|
||||
let lmap: [String] = organ_lex("elp/data/lexicon.psv")
|
||||
|
||||
// 5: render a line FROM MEANING in Will's voice
|
||||
let vw: [String] = voice_will(native_list_get(g, 0), native_list_get(g, 1), native_list_get(g, 2))
|
||||
let t: String = sem_realize(sem_frame("greet", "Will", "", ""))
|
||||
let codes: [String] = text_phonemes(lmap, t)
|
||||
println("[render] \"" + t + "\" :: " + list_join(codes, " ") + " in voice=will f0=" + int_to_str(voice_get_int(vw, "f0")) + " kf=" + int_to_str(voice_get_int(vw, "kf")))
|
||||
let samples: [Int] = synth_codes(codes, vw, pmap)
|
||||
let ok: Bool = write_wav(samples, 16000, outdir + "will-reply.wav")
|
||||
println("[done] will-reply.wav=" + bool_to_str(ok))
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// speech-voice-demo2.el - LIVE VOICE LOOP on Will's richer 30s read, with a
|
||||
// GEOMETRIC SET-REPLACE of the voice_will manifold (supersede the coarse 10s
|
||||
// region, insert the 30s region — no duplicate node, no per-node CRUD; Will's
|
||||
// standing rule f999c5ff). HONEST: 30s steadies the 11-number average over more
|
||||
// of his vowels, but it is still one formant triple with no coarticulation or
|
||||
// prosody — closer but still synthetic, not a clone.
|
||||
|
||||
fn main() {
|
||||
let outdir: String = "/Users/will/Development/neuron-technologies/foundation/el/.claude/worktrees/agent-acc02900ef4ade35e/elp/tests/examples/out/"
|
||||
let vp: String = "/private/tmp/claude-501/-Users-will/6531446d-bc27-4095-930b-e04777c3db4f/scratchpad/will30-voiceprint.json"
|
||||
let manifest: String = "elp/data/will-voice.engram.json"
|
||||
|
||||
// --- SET-REPLACE step 1: read the PRIOR region (text read of the manifold
|
||||
// file — no engram_load, so the store stays clean) and report what is
|
||||
// being superseded. ---
|
||||
let prior: String = fs_read(manifest)
|
||||
let pp: Int = str_index_of(prior, "voice will ")
|
||||
if pp >= 0 {
|
||||
let pw: String = str_slice(prior, pp, pp + 200)
|
||||
println("[set-replace] superseding PRIOR voice region: f0=" + int_to_str(parse_uint_from(pw, "f0=")) + " kf=" + int_to_str(parse_uint_from(pw, "kf=")) + " f1=" + int_to_str(parse_uint_from(pw, "f1=")))
|
||||
}
|
||||
|
||||
// --- step 2: reshape the 30s voiceprint -> organ voice-signature source ---
|
||||
let sig: [Int] = reshape_voiceprint(vp, "elp/data/will-voice.json")
|
||||
|
||||
// --- step 3: INSERT the fresh 30s region into an EMPTY engram and save ->
|
||||
// wholesale replaces the manifold file (old region dropped, not edited,
|
||||
// not duplicated). This is the geometric set-replace. ---
|
||||
let ig: Int = ingest_voice(sig, manifest)
|
||||
|
||||
// --- step 4: READ the new target BACK from geometry ---
|
||||
let g: [Int] = load_voice(manifest)
|
||||
println("[voice-geometry] new region read from manifold: f0=" + int_to_str(native_list_get(g, 0)) + " f0_end=" + int_to_str(native_list_get(g, 1)) + " kf=" + int_to_str(native_list_get(g, 2)) + " f1=" + int_to_str(native_list_get(g, 3)) + " f2=" + int_to_str(native_list_get(g, 4)) + " f3=" + int_to_str(native_list_get(g, 5)) + " (measured 30s, COARSE — not a clone)")
|
||||
|
||||
// phoneme + lexicon geometry from the organ (loaded after the voice sig is
|
||||
// cached in EL, since engram_load replaces the store)
|
||||
let pmap: [String] = organ_pmap("elp/data/phonetics-formants.engram.json")
|
||||
let lmap: [String] = organ_lex("elp/data/lexicon.psv")
|
||||
|
||||
// --- step 5: render a fresh reply FROM MEANING in the 30s Will voice ---
|
||||
let vw: [String] = voice_will(native_list_get(g, 0), native_list_get(g, 1), native_list_get(g, 2))
|
||||
let t: String = sem_realize(sem_frame("greet", "Will", "", ""))
|
||||
let codes: [String] = text_phonemes(lmap, t)
|
||||
println("[render] \"" + t + "\" :: " + list_join(codes, " ") + " in voice=will f0=" + int_to_str(voice_get_int(vw, "f0")) + " kf=" + int_to_str(voice_get_int(vw, "kf")))
|
||||
let samples: [Int] = synth_codes(codes, vw, pmap)
|
||||
let ok: Bool = write_wav(samples, 16000, outdir + "will-reply2.wav")
|
||||
println("[done] will-reply2.wav=" + bool_to_str(ok))
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// speech-voicegeom-demo.el - THE JUMP: render Will's VOWEL SPACE + PROSODY
|
||||
// (measured over 30s), not the single 11-number average. His vowels land at HIS
|
||||
// targets; pitch follows HIS melody. All read back FROM the ingested geometry.
|
||||
// INTERIM: the geometry was Python-measured (measure_voice.py, numpy LPC/F0) —
|
||||
// to be superseded by the engram-measures-audio path. No source layer.
|
||||
|
||||
fn main() {
|
||||
let outdir: String = "/Users/will/Development/neuron-technologies/foundation/el/.claude/worktrees/agent-acc02900ef4ade35e/elp/tests/examples/out/"
|
||||
|
||||
// 1: ingest vowel space + prosody as geometry (empty store -> save; set-replace)
|
||||
let ig: Int = ingest_voicegeom("elp/data/will-vowelspace.psv", "elp/data/will-prosody.psv", "elp/data/will-voicegeom.engram.json")
|
||||
// kf (vocal-tract scale for consonants) from the earlier will-voice manifold
|
||||
let sigv: [Int] = load_voice("elp/data/will-voice.engram.json")
|
||||
let kf: Int = native_list_get(sigv, 2)
|
||||
// 2: read vowel space + prosody back FROM geometry
|
||||
let vmap: [String] = load_voicegeom("elp/data/will-voicegeom.engram.json")
|
||||
let pros: [Int] = prosody_from(vmap)
|
||||
println("[geometry] vowels=" + int_to_str((native_list_len(vmap) - 2) / 2) + " prosody f0_median=" + int_to_str(native_list_get(pros, 0)) + " f0_min=" + int_to_str(native_list_get(pros, 1)) + " f0_max=" + int_to_str(native_list_get(pros, 2)) + " kf=" + int_to_str(kf))
|
||||
let ehv: [Int] = vmap_get(vmap, "EH")
|
||||
let ihv: [Int] = vmap_get(vmap, "IH")
|
||||
println("[his-vowels] EH=" + int_to_str(native_list_get(ehv, 0)) + "/" + int_to_str(native_list_get(ehv, 1)) + " IH=" + int_to_str(native_list_get(ihv, 0)) + "/" + int_to_str(native_list_get(ihv, 1)))
|
||||
|
||||
// phoneme geometry from the organ (loaded AFTER caches are in EL)
|
||||
let pmap: [String] = organ_pmap("elp/data/phonetics-formants.engram.json")
|
||||
let lmap: [String] = organ_lex("elp/data/lexicon.psv")
|
||||
|
||||
// 3+4: render FROM MEANING in his-vowels + his-prosody voice
|
||||
let vw: [String] = voice_will(native_list_get(pros, 0), native_list_get(pros, 1), kf)
|
||||
let noacc: [String] = native_list_empty()
|
||||
let novset: [String] = native_list_empty()
|
||||
let t: String = sem_realize(sem_frame("greet", "Will", "", ""))
|
||||
let codes: [String] = text_phonemes(lmap, t)
|
||||
println("[render] \"" + t + "\" :: " + list_join(codes, " "))
|
||||
let samples: [Int] = synth_codes_accent(codes, vw, pmap, noacc, novset, vmap, pros)
|
||||
let ok: Bool = write_wav(samples, 16000, outdir + "will-reply3.wav")
|
||||
println("[done] will-reply3.wav=" + bool_to_str(ok))
|
||||
}
|
||||
Reference in New Issue
Block a user