code wiki / _hdl_build / nx_skill_coach_speech.nx
nx_skill_coach_speech.nx source
↩ module page · 57 lines · 4380 B
1// nx_skill_coach_speech.nx -- SKILL-COACH audio-PROSODY adapter (the operator's "convincing capability in how i
2// speak" + the hypnotist's voice + public speaking/acting). SENSOR-coach: from prosodic features (pace, pitch-
3// variety, pause-control, fillers) -> grade each dimension -> diagnose -> DRILL. Perception composes the gated audio
4// stack (nx_pitch over time = pitch-variety + energy/silence = pauses; fillers via ASR = a later rung); here features
5// are passed in (like R1 passed known F0s). Thresholds inline at R1 (-> R2 rubric-store, rule#11). NO floats.
6// Self-gate: 3 speaker profiles (confident / nervous / hesitant) -> correct issue diagnosis. license_tier: ORIGINAL
7import "nx_syscalls.nx"
8import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc)
9
10const PACE_LO: i64 = 110 // words/min: < = too slow
11const PACE_HI: i64 = 170 // > = too fast
12const PITCH_VAR_MIN: i64 = 200 // cents range of speaking pitch: < = monotone
13const PAUSE_LO: i64 = 8 // % time in pauses: < = rushed
14const PAUSE_HI: i64 = 30 // > = hesitant
15const FILLER_HI: i64 = 4 // fillers per 100 words: > = too many
16
17func sp_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
18// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer
19// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the
20// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls).
21// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign.
22func sp_putn(v: i64) -> i64 { nxi_out(v); return 0 }
23// grade + drill for one speaking attempt; returns the count of issues (0 = convincing)
24func speech_coach(wpm: i64, pitch_range: i64, pause_pct: i64, fillers_per100: i64) -> i64 {
25 var issues: i64 = 0
26 // PACE
27 if wpm > PACE_HI { sp_puts(" PACE too fast -> slow down, let points land; DRILL: metered reading to target wpm\n" as *u8); issues = issues + 1 }
28 else { if wpm < PACE_LO { sp_puts(" PACE too slow -> lift the energy; DRILL: time a passage up to target wpm\n" as *u8); issues = issues + 1 } }
29 // PITCH VARIETY (the #1 'convincing' lever -- monotone kills persuasion)
30 if pitch_range < PITCH_VAR_MIN { sp_puts(" MONOTONE -> vary pitch to mark emphasis; DRILL: exaggerated-intonation reading\n" as *u8); issues = issues + 1 }
31 // PAUSE CONTROL
32 if pause_pct < PAUSE_LO { sp_puts(" RUSHED (no pauses) -> add strategic pauses for weight; DRILL: mark 3 pause points\n" as *u8); issues = issues + 1 }
33 else { if pause_pct > PAUSE_HI { sp_puts(" HESITANT (too many pauses) -> tighten, project certainty; DRILL: continuous-flow reading\n" as *u8); issues = issues + 1 } }
34 // FILLERS
35 if fillers_per100 > FILLER_HI { sp_puts(" FILLERS (um/uh) -> replace with silence; DRILL: silent-pause practice\n" as *u8); issues = issues + 1 }
36 if issues == 0 { sp_puts(" CONVINCING + CONFIDENT delivery -> advance (try a tougher passage / a skeptical audience)\n" as *u8) }
37 return issues
38}
39func sp_attempt(label: *u8, wpm: i64, pr: i64, pp: i64, f: i64) -> i64 {
40 sp_puts(" ["); sp_puts(label); sp_puts(" wpm="); sp_putn(wpm); sp_puts(" pitchRange="); sp_putn(pr)
41 sp_puts("c pause%="); sp_putn(pp); sp_puts(" fillers/100="); sp_putn(f); sp_puts("]\n" as *u8)
42 return speech_coach(wpm, pr, pp, f)
43}
44func main() -> i64 {
45 sp_puts("SKILL-COACH (speech/prosody): convincing delivery / hypnotist's voice / public speaking\n" as *u8)
46 var pass: i64 = 0
47 // confident, persuasive speaker -> 0 issues
48 if sp_attempt("confident" as *u8, 145, 350, 18, 2) == 0 { pass = pass + 1 }
49 // nervous speaker: too fast + monotone + rushed + fillers -> 4 issues
50 if sp_attempt("nervous" as *u8, 185, 120, 3, 8) == 4 { pass = pass + 1 }
51 // hesitant speaker: too slow + too many pauses -> 2 issues
52 if sp_attempt("hesitant" as *u8, 100, 300, 40, 3) == 2 { pass = pass + 1 }
53 sp_puts(" speech-coach diagnoses correct = "); sp_putn(pass); sp_puts("/3\n" as *u8)
54 if pass == 3 { sp_puts("SKILL-COACH-SPEECH: GREEN -- prosody->grade->diagnose->drill; the 'convincing voice' / hypnosis / public-speaking adapter on the audio stack\n" as *u8); return 0 }
55 sp_puts("SKILL-COACH-SPEECH: RED\n" as *u8)
56 return 1
57}