code wiki / _hdl_build / nx_live_xlate_call.nx

nx_live_xlate_call.nx source

↩ module page · 26 lines · 1410 B

1// nx_live_xlate_call.nx -- the CALL-LEVEL live-translation router for a 2-party video call. Each peer has a 2// locale; a spoken utterance (recognized text) is translated into the LISTENER's language so each person reads 3// the other in their own script. Same-locale = passthrough. Composes nx_mt_ruen. This is the deterministic, 4// on-device call logic for "a girl in Belarus (RU) talking to a boy in Texas (EN)". The audio->text step (ASR) 5// is the declared interface + RESEARCHER long-pole (V-ASR-1); transport is the existing relay (cross-NAT by 6// construction). license_tier: ORIGINAL 7import "nx_syscalls.nx" 8import "nx_mt_ruen.nx" 9 10const LX_EN: i64 = 0 11const LX_RU: i64 = 1 12 13// translate utterance `utt` (n bytes, spoken in `speaker` locale) into the `listener` locale -> dst. returns dstlen. 14func lx_caption_for_listener(utt: *u8, n: i64, speaker: i64, listener: i64, dst: *u8, cap: i64) -> i64 { 15 if speaker == listener { 16 var i: i64 = 0 17 while i < n { if i < cap { dst[i] = utt[i] } i = i + 1 } 18 return n 19 } 20 if speaker == LX_EN { if listener == LX_RU { return nx_ruen_translate(utt, n, 0, dst, cap) } } 21 if speaker == LX_RU { if listener == LX_EN { return nx_ruen_translate(utt, n, 1, dst, cap) } } 22 // unsupported language pair -> copy verbatim (never drop content) 23 var j: i64 = 0 24 while j < n { if j < cap { dst[j] = utt[j] } j = j + 1 } 25 return n 26}