code wiki / (root) / nx_tts_speak.nx

nx_tts_speak.nx

buildroot/runtime/nx_tts_speak.nx

16361 B312 linesdepth 5pulls 8 transitivereach 0 importersview sourcekind tooltopic tts
docsdependenciesstructsconstsfunctions

about

nx_tts_speak.nx -- R2.3: TEXT-TO-SPEECH. The GENERATOR that supersedes the fixed-word demos (nx_tts_word "hi", nx_tts_seq "hello"): a grapheme-to-phoneme (G2P) front-end maps ANY English text -> a phoneme sequence, then the phoneme synthesizer (formant source-filter, continuous cascade state = the proven nx_tts_seq core) renders it to a WAV. G2P = a small EXCEPTION DICTIONARY for common irregular words (English spelling is irregular: "love","you" don't follow rules) + rule-based letter->sound with digraph lookahead (th/sh/ch/ee/oo/ai/...) for the rest -- exactly how real G2P works (dict + rules fallback). Synthesizes "i love you" (inventory-friendly, no plosives) to web_assets for /listen. Robotic formant quality (honest), but it now generalizes past 2 words. license_tier: ORIGINAL expect_exit: 0

dependencies 5 imports · 0 importers

nx_syscalls.nx nx_f32.nx nx_f32_sincos.nx nx_f32_exp.nx nx_f32_cvt.nx nx_tts_speak.nx

imports: nx_syscalls.nxnx_f32.nxnx_f32_sincos.nxnx_f32_exp.nxnx_f32_cvt.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main tw sys_write sys_mmap build_tables set_ph g2p sys_mmap ↻ emit dict_word lc emit ↻ streq lc ↻ rules_word lc ↻ emit ↻ letter_ph lc ↻ tn sys_mmap ↻ sys_write ↻ render sys_mmap ↻ reson_ab nx_i32_to_f32 nx_f32_div nx_f32_classify nx_f32_exp_field nx_f32_mant_field nx_f32_sign nx_f32_mant_field ↻ nx_f32_exp_field ↻ nx_f32_mul nx_f32_classify ↻ nx_f32_sign ↻ nx_f32_mant_field ↻ nx_f32_exp_field ↻ nx_f32_exp nx_f32_classify ↻

structs

none

consts

13const F_MAGIC_1500: i64 = 1500
14const F_MAGIC_2500: i64 = 2500
15const F_MAGIC_1150: i64 = 1150
16const F_MAGIC_2900: i64 = 2900
17const F_MAGIC_1850: i64 = 1850
18const F_MAGIC_2250: i64 = 2250
19const F_MAGIC_1200: i64 = 1200
20const F_MAGIC_1100: i64 = 1100
21const F_MAGIC_2200: i64 = 2200
22const F_MAGIC_1700: i64 = 1700
23const F_MAGIC_2700: i64 = 2700
24const F_MAGIC_1300: i64 = 1300
25const F_MAGIC_1600: i64 = 1600
26const F_MAGIC_2400: i64 = 2400
27const F_MAGIC_1400: i64 = 1400
28const F_MAGIC_5000: i64 = 5000
29const F_MAGIC_7000: i64 = 7000
30const F_MAGIC_8000: i64 = 8000
31const F_MAGIC_2000: i64 = 2000
32const F_MAGIC_3000: i64 = 3000
33const F_MAGIC_4000: i64 = 4000
34const F_MAGIC_6000: i64 = 6000
35const F_MAGIC_1103515245: i64 = 1103515245
36const F_MAGIC_12345: i64 = 12345
37const F_MAGIC_32768: i64 = 32768
38const F_MAGIC_131072: i64 = 131072
39const F_MAGIC_32767: i64 = 32767
41const SR: i64 = 16000
42const F_PI: i64 = 0x40490FDB
43const F_2PI: i64 = 0x40C90FDB
44const F_ONE: i64 = 0x3F800000
46const EXC_VOICED: i64 = 0
47const EXC_NASAL: i64 = 1
48const EXC_NOISE: i64 = 2
49const EXC_VFRIC: i64 = 3
50const EXC_SIL: i64 = 4
52const P_SIL: i64=0
53const P_A: i64=1 // ah (father)
54const P_E: i64=2 // eh (bet)
55const P_I: i64=3 // ee (see)
56const P_O: i64=4 // oh (go)
57const P_U: i64=5 // oo (boot)
58const P_UH: i64=6 // uh (cup/schwa)
59const P_M: i64=7
60const P_N: i64=8
61const P_L: i64=9
62const P_R: i64=10
63const P_H: i64=11
64const P_V: i64=12
65const P_Z: i64=13
66const P_S: i64=14
67const P_F: i64=15
68const P_W: i64=16
69const P_Y: i64=17
70const P_SH: i64=18
71const NPH: i64=19
72const WAV_PATH: *u8 = "/mnt/c/Users/elder/nishi-core/nxc2/web_assets/ng_elara_iloveyou.wav" as *u8

functions

74func tw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main calls 1: sys_write
75func tn(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{sys_write(1,"-" as *u8,1);m=0-m} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1} sys_write(1,bb,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
78func set_ph(f1: *i64, f2: *i64, f3: *i64, ex: *i64, id: i64, a: i64, b: i64, c: i64, e: i64) -> i64 { f1[id]=a; f2[id]=b; f3[id]=c; ex[id]=e; return 0 }
called by 1: build_tables
79func build_tables(f1: *i64, f2: *i64, f3: *i64, ex: *i64) -> i64
called by 1: main calls 1: set_ph
103func lc(c: u8) -> u8 { if c>=(65 as u8) { if c<=(90 as u8) { return (c+(32 as u8)) as u8 } } return c }
104func streq(a: *u8, b: *u8, n: i64) -> i64 { var i: i64=0; while i<n { if lc(a[i])!=b[i] { return 0 } i=i+1 } return 1 }
called by 1: dict_word calls 1: lc
106func emit(out: *i64, o: *i64, id: i64) -> i64 { out[o[0]]=id; o[0]=o[0]+1; return 0 }
109func dict_word(w: *u8, wl: i64, out: *i64, o: *i64) -> i64
called by 1: g2p calls 3: lcemitstreq
121func letter_ph(c: u8) -> i64
called by 1: rules_word calls 1: lc
141func rules_word(w: *u8, wl: i64, out: *i64, o: *i64) -> i64
called by 1: g2p calls 3: lcemitletter_ph
155func g2p(text: *u8, tl: i64, out: *i64) -> i64
178func reson_ab(F: i64, BW: i64, out2: *i64) -> i64
187func cascade(x: i64, ab: *i64, st: *i64) -> i64
called by 1: render calls 2: nx_f32_addnx_f32_mul
195func f32_to_int(m: i64) -> i64
called by 1: main
203func glottal(phase: i64, period: i64) -> i64
called by 1: render calls 2: nx_f32_divnx_i32_to_f32
211func prng(st: *i64) -> i64 { st[0] = (st[0]*F_MAGIC_1103515245 + F_MAGIC_12345) & 0x7FFFFFFF; return st[0] }
called by 1: render
212func pB(buf: *u8, po: *i64, b: i64) -> i64 { buf[po[0]] = (b & 0xFF) as u8; po[0]=po[0]+1; return 0 }
called by 2: pU16pU32
213func pU16(buf: *u8, po: *i64, v: i64) -> i64 { pB(buf,po,v); pB(buf,po,v>>8); return 0 }
called by 1: main calls 1: pB
214func pU32(buf: *u8, po: *i64, v: i64) -> i64 { pB(buf,po,v); pB(buf,po,v>>8); pB(buf,po,v>>16); pB(buf,po,v>>24); return 0 }
called by 1: main calls 1: pB
215func pStr(buf: *u8, po: *i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){ buf[po[0]]=s[i]; po[0]=po[0]+1; i=i+1 } return 0 }
called by 1: main
218func render(id: i64, f1: *i64, f2: *i64, f3: *i64, ex: *i64, dur: i64, smp: *i64, so: *i64, st: *i64, rng: *i64, ntotal: i64, pacc: *i64) -> i64
250func main() -> i64