summaryrefslogtreecommitdiff
path: root/web/index.html
diff options
context:
space:
mode:
authorwuhei <wuhei@users.noreply.github.com>2026-11-19 11:54:17 +0100
committerwuhei <wuhei@users.noreply.github.com>2026-11-19 11:54:17 +0100
commit10ee627143419d6e9c9186fbb0a023a34b08948e (patch)
treea9f2a4fc1beae1911a4e89421587039d9eae561d /web/index.html
downloadlilchinese-10ee627143419d6e9c9186fbb0a023a34b08948e.tar.gz
lilchinese: local streaming Chinese ASR rendered as fullscreen Takahashi slides
parec mic -> sherpa-onnx streaming zipformer (zh, int8, offline) -> slide splitter -> SSE -> Firefox kiosk. No cloud, no Web Speech API. - 20ms audio reads, ~35ms capture-to-paint overhead, 320ms model lookahead - slides break on punctuation or at -chars; short tails don't blank a full slide - autofit font (Noto Sans CJK SC Black), 90ms slam transition, SSE reconnect - -record captures screen+mic via ffmpeg x11grab+pulse, finalized on Ctrl+C - -wav plays a file through the pipeline for testing
Diffstat (limited to 'web/index.html')
-rw-r--r--web/index.html122
1 files changed, 122 insertions, 0 deletions
diff --git a/web/index.html b/web/index.html
new file mode 100644
index 0000000..4838047
--- /dev/null
+++ b/web/index.html
@@ -0,0 +1,122 @@
+<!doctype html>
+<html lang="zh-Hans">
+<head>
+<meta charset="utf-8">
+<title>lilchinese</title>
+<style>
+ :root { --pad-y: 7vh; --pad-x: 5vw; }
+ html, body {
+ margin: 0; padding: 0; height: 100%; overflow: hidden;
+ background: #fff; color: #000; cursor: none;
+ -webkit-user-select: none; user-select: none;
+ font-family: "Noto Sans CJK SC Black", "Noto Sans SC Black", "Source Han Sans SC",
+ "Noto Sans CJK JP Black", "PingFang SC", sans-serif;
+ }
+ #wrap {
+ position: fixed; inset: 0; box-sizing: border-box;
+ padding: var(--pad-y) var(--pad-x);
+ display: flex; align-items: center; justify-content: center;
+ }
+ #t {
+ font-weight: 900;
+ line-height: 1.04;
+ letter-spacing: .02em;
+ text-align: center;
+ white-space: pre-wrap;
+ overflow-wrap: anywhere;
+ text-wrap: balance;
+ max-width: 100%;
+ will-change: font-size;
+ }
+ @keyframes pop {
+ from { opacity: .5; transform: scale(.955); }
+ to { opacity: 1; transform: scale(1); }
+ }
+ #t.pop { animation: pop 90ms ease-out; }
+ #d {
+ position: fixed; right: 12px; bottom: 10px; display: none;
+ font: 12px/1.4 ui-monospace, monospace; color: #bbb; letter-spacing: 0;
+ }
+</style>
+</head>
+<body>
+<div id="wrap"><div id="t"></div></div>
+<div id="d"></div>
+<script>
+(function () {
+ const wrap = document.getElementById('wrap');
+ const t = document.getElementById('t');
+ const d = document.getElementById('d');
+ const q = new URLSearchParams(location.search);
+ const debug = q.has('debug');
+ if (debug) d.style.display = 'block';
+
+ let cur = '';
+ let padW = 0, padH = 0;
+
+ function measurePad() {
+ const cs = getComputedStyle(wrap);
+ padW = parseFloat(cs.paddingLeft) + parseFloat(cs.paddingRight);
+ padH = parseFloat(cs.paddingTop) + parseFloat(cs.paddingBottom);
+ }
+
+ // Largest font size at which the whole phrase still fits the screen.
+ function fit() {
+ const boxW = wrap.clientWidth - padW;
+ const boxH = wrap.clientHeight - padH;
+ if (boxW <= 0 || boxH <= 0) return;
+ let lo = 8, hi = Math.max(boxW, boxH) * 1.7;
+ for (let i = 0; i < 18; i++) {
+ const mid = (lo + hi) / 2;
+ t.style.fontSize = mid + 'px';
+ const r = t.getBoundingClientRect();
+ if (r.width <= boxW && r.height <= boxH) lo = mid; else hi = mid;
+ }
+ t.style.fontSize = Math.floor(lo) + 'px';
+ }
+
+ function render(text, cap) {
+ if (!text || text === cur) return;
+ const growing = cur.length > 0 && text.startsWith(cur);
+ t.textContent = text;
+ if (!growing) {
+ // New phrase: slam it in. Refinements just update in place (no flicker).
+ t.classList.remove('pop');
+ void t.offsetWidth;
+ t.classList.add('pop');
+ }
+ cur = text;
+ fit();
+ if (debug) {
+ const lat = cap ? (Date.now() - cap) : 0;
+ d.textContent = text.length + '\u5b57 ' + (cap ? lat + 'ms' : '');
+ }
+ }
+
+ addEventListener('resize', function () { measurePad(); fit(); });
+ addEventListener('keydown', function (e) {
+ if (e.key === 'f' || e.key === 'F') {
+ if (document.fullscreenElement) document.exitFullscreen();
+ else document.documentElement.requestFullscreen();
+ }
+ });
+
+ measurePad();
+
+ if (q.has('text')) {
+ render(q.get('text'), 0); // design preview: index.html?text=你好世界
+ return;
+ }
+
+ const es = new EventSource('/events');
+ es.onmessage = function (e) {
+ try {
+ const s = JSON.parse(e.data);
+ render(s.text, s.cap);
+ } catch (_) {}
+ };
+ es.onerror = function () { /* EventSource reconnects on its own; keep the last phrase up */ };
+})();
+</script>
+</body>
+</html>