Spaces:
Running

File size: 19,199 Bytes
e009f2c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54d222e
e009f2c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="./support.js"></script>
</head>
<body>
<x-dc>
<helmet>
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="" />
  <link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet" />
  <style>
    body { margin: 0; background: #0A0B0B; }
    a { color: #E9A23B; text-decoration: none; border-bottom: 1px solid #3a2f16; }
    a:hover { color: #F3F1EB; }
  </style>
</helmet>
<div style="min-height: 100vh; background: #0A0B0B; color: #F3F1EB; font-family: 'Space Grotesk', system-ui, sans-serif; padding: 72px 0 120px; background-image: linear-gradient(to right, #17191800 0, #171918 1px, transparent 1px), linear-gradient(to bottom, #171918 1px, transparent 1px); background-size: 80px 80px;">
  <div style="max-width: 1040px; margin: 0 auto; padding: 0 40px; display: flex; flex-direction: column; gap: 64px;">

    <header style="display: flex; flex-direction: column; gap: 28px;">
      <div style="display: flex; justify-content: space-between; align-items: baseline; font: 500 12px 'JetBrains Mono', monospace; letter-spacing: 0.28em; color: #83857E;">
        <span>KUGGUK LABS · OBSERVATION LOG</span>
        <span style="color: #E9A23B;">RCV · LOCAL ONLY</span>
      </div>
      <h1 style="margin: 0; font: 600 76px/1.02 'Space Grotesk', sans-serif; letter-spacing: -0.035em;">Three seconds,<br /><span style="color: #E9A23B;">stored offline.</span></h1>
      <div style="display: grid; grid-template-columns: 1fr 320px; gap: 40px; align-items: start;">
        <p style="margin: 0; font: 400 24px/1.5 'Space Grotesk', sans-serif; color: #C7C6BF;">RCV takes a 3 second voice recording, keeps it on the device, and applies it to zyntalic text locally, so playback adapts and improves with use. No upload, no round trip, no server-side copy of a voice.</p>
        <figure style="margin: 0; display: flex; flex-direction: column; gap: 12px;">
          <div style="display: flex; justify-content: space-between; font: 500 11px 'JetBrains Mono', monospace; letter-spacing: 0.22em; color: #83857E;"><span>SPECIMEN 001</span><span style="color: #E9A23B;">K2 · 8,611M</span></div>
          <div style="border: 1px solid #232624; background: #0E100F; padding: 8px;">
            <div style="overflow: hidden; height: 168px;">
              <img src="./assets/zebra-k2.png" alt="Field unit on K2" style="width: 168%; margin-left: -34%; display: block; filter: saturate(0.5) contrast(1.06) brightness(0.86) sepia(0.12);" />
            </div>
          </div>
          <figcaption style="font: 400 12px/1.5 'JetBrains Mono', monospace; letter-spacing: 0.04em; color: #5f615c;">field unit · observed, unbothered</figcaption>
        </figure>
      </div>
    </header>

    <section style="display: flex; flex-direction: column; gap: 24px;">
      <div style="font: 500 12px 'JetBrains Mono', monospace; letter-spacing: 0.28em; color: #83857E;">01 — PIPELINE</div>
      <div style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px;">
        <div style="border: 1px solid #232624; background: #0E100F; padding: 24px;">
          <div style="font: 500 11px 'JetBrains Mono', monospace; letter-spacing: 0.24em; color: #E9A23B;">CAPTURE</div>
          <div style="margin-top: 14px; font: 400 22px/1.3 'Space Grotesk', sans-serif;">3s from the mic</div>
        </div>
        <div style="border: 1px solid #232624; background: #0E100F; padding: 24px;">
          <div style="font: 500 11px 'JetBrains Mono', monospace; letter-spacing: 0.24em; color: #E9A23B;">STORE</div>
          <div style="margin-top: 14px; font: 400 22px/1.3 'Space Grotesk', sans-serif;">IndexedDB, this origin</div>
        </div>
        <div style="border: 1px solid #232624; background: #0E100F; padding: 24px;">
          <div style="font: 500 11px 'JetBrains Mono', monospace; letter-spacing: 0.24em; color: #E9A23B;">COMPUTE</div>
          <div style="margin-top: 14px; font: 400 22px/1.3 'Space Grotesk', sans-serif;">WebGPU → WASM → CPU</div>
        </div>
        <div style="border: 1px solid #232624; background: #0E100F; padding: 24px;">
          <div style="font: 500 11px 'JetBrains Mono', monospace; letter-spacing: 0.24em; color: #E9A23B;">PLAYBACK</div>
          <div style="margin-top: 14px; font: 400 22px/1.3 'Space Grotesk', sans-serif;">adapts each replay</div>
        </div>
      </div>
    </section>

    <section style="display: flex; flex-direction: column; gap: 24px;">
      <div style="display: flex; justify-content: space-between; align-items: baseline;">
        <div style="font: 500 12px 'JetBrains Mono', monospace; letter-spacing: 0.28em; color: #83857E;">02 — TIERS ON THIS DEVICE</div>
        <div style="font: 500 12px 'JetBrains Mono', monospace; letter-spacing: 0.2em; color: #E9A23B;">SELECTED: {{ tierLabel }}</div>
      </div>
      <div style="display: flex; flex-direction: column; gap: 12px;">
        <sc-for list="{{ tiers }}" as="t" hint-placeholder-count="3">
          <div style="display: grid; grid-template-columns: 132px 1fr 200px; gap: 24px; align-items: center; border: 1px solid #232624; background: #0E100F; padding: 22px 26px;">
            <div style="font: 500 18px 'JetBrains Mono', monospace; letter-spacing: 0.1em;">{{ t.name }}</div>
            <div style="font: 400 19px/1.4 'Space Grotesk', sans-serif; color: #C7C6BF;">{{ t.detail }}</div>
            <div style="font: 500 12px 'JetBrains Mono', monospace; letter-spacing: 0.22em; text-align: right;">{{ t.status }}</div>
          </div>
        </sc-for>
      </div>
      <div style="font: 400 16px/1.6 'Space Grotesk', sans-serif; color: #83857E;">The tiers are a fallback chain, not a feature ladder: the same transform runs on all three, only the throughput differs. Hardware concurrency reported: {{ cores }}.</div>
    </section>

    <section style="display: flex; flex-direction: column; gap: 24px;">
      <div style="font: 500 12px 'JetBrains Mono', monospace; letter-spacing: 0.28em; color: #83857E;">03 — LIVE PROBE</div>
      <div style="border: 1px solid #232624; background: #0E100F; padding: 40px; display: flex; flex-direction: column; gap: 30px;">
        <div style="display: flex; gap: 20px; align-items: center; flex-wrap: wrap;">
          <button onClick="{{ record }}" style="font: 500 14px 'JetBrains Mono', monospace; letter-spacing: 0.18em; padding: 18px 30px; min-height: 44px; background: #E9A23B; color: #0A0B0B; border: none; cursor: pointer;" style-hover="background: #F3B54F;">RECORD 3s</button>
          <button onClick="{{ play }}" style="font: 500 14px 'JetBrains Mono', monospace; letter-spacing: 0.18em; padding: 18px 30px; min-height: 44px; background: transparent; color: #F3F1EB; border: 1px solid #3a3d3a; cursor: pointer;" style-hover="border-color: #E9A23B; color: #E9A23B;">REPLAY LOCALLY</button>
          <button onClick="{{ wipe }}" style="font: 500 14px 'JetBrains Mono', monospace; letter-spacing: 0.18em; padding: 18px 30px; min-height: 44px; background: transparent; color: #83857E; border: 1px solid #232624; cursor: pointer;" style-hover="color: #F3F1EB;">WIPE</button>
          <div style="font: 500 13px 'JetBrains Mono', monospace; letter-spacing: 0.16em; color: #E9A23B;">{{ status }}</div>
        </div>
        <div style="height: 96px; border-bottom: 1px solid #232624; display: flex; align-items: flex-end; gap: 2px;">
          <sc-for list="{{ wave }}" as="bar" hint-placeholder-count="64">
            <div style="flex: 1; background: #E9A23B; opacity: 0.85; min-height: 1px; height: {{ bar.h }}"></div>
          </sc-for>
        </div>
        <div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; font: 400 15px/1.5 'Space Grotesk', sans-serif; color: #83857E;">
          <div>Replays: <span style="color: #F3F1EB;">{{ plays }}</span></div>
          <div>Adapted rate: <span style="color: #F3F1EB;">{{ rate }}</span></div>
          <div>Bytes held locally: <span style="color: #F3F1EB;">{{ bytes }}</span></div>
        </div>
      </div>
    </section>

    <section style="display: flex; flex-direction: column; gap: 20px;">
      <div style="font: 500 12px 'JetBrains Mono', monospace; letter-spacing: 0.28em; color: #83857E;">04 — THE IMPOSSIBLE PART</div>
      <p style="margin: 0; max-width: 860px; font: 400 32px/1.4 'Space Grotesk', sans-serif; letter-spacing: -0.02em;">Believing this works for most users locally, with <span style="color: #E9A23B;">no legal trace and no proof of work</span>.</p>
      <p style="margin: 0; max-width: 780px; font: 400 19px/1.65 'Space Grotesk', sans-serif; color: #C7C6BF;">Runs entirely on your device. No upload, no account, no server copy — disconnect the wifi and it still works.</p>
    </section>

    <section style="display: flex; flex-direction: column; gap: 18px;">
      <div style="font: 500 12px 'JetBrains Mono', monospace; letter-spacing: 0.28em; color: #83857E;">05 — LIMITATIONS</div>
      <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 16px;">
        <div style="border-left: 1px solid #E9A23B; padding: 4px 0 4px 22px; font: 400 18px/1.5 'Space Grotesk', sans-serif; color: #C7C6BF;">3 seconds is a thin sample. Quality varies by voice, microphone and room.</div>
        <div style="border-left: 1px solid #E9A23B; padding: 4px 0 4px 22px; font: 400 18px/1.5 'Space Grotesk', sans-serif; color: #C7C6BF;">WebGPU availability is uneven; most devices land on the WASM or CPU tier.</div>
        <div style="border-left: 1px solid #E9A23B; padding: 4px 0 4px 22px; font: 400 18px/1.5 'Space Grotesk', sans-serif; color: #C7C6BF;">Storage is per-browser, per-origin. Clearing site data destroys the recording, by design.</div>
        <div style="border-left: 1px solid #E9A23B; padding: 4px 0 4px 22px; font: 400 18px/1.5 'Space Grotesk', sans-serif; color: #C7C6BF;">The absence of a trace is a deliberate property, not an oversight.</div>
      </div>
      <div style="margin-top: 20px; font: 400 15px/1.6 'JetBrains Mono', monospace; color: #5f615c;">This page probes real capabilities and records real audio into local storage. The transform is a sample-level pitch and gain kernel, not a voice model.</div>
    </section>
  </div>
</div>
</x-dc>
<script type="text/x-dc" data-dc-script>
class Component extends DCLogic {
  state = {
    gpu: 'probing', gpuName: '', simd: 'probing', cores: '—',
    tier: '—', status: 'IDLE', plays: 0, rate: 1, bytes: 0, wave: []
  };

  componentDidMount() {
    const cores = navigator.hardwareConcurrency || '—';
    let simd = false;
    try {
      simd = WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]));
    } catch (e) { simd = false; }
    this.setState({ cores, simd: simd ? 'available' : 'unavailable' });
    if (navigator.gpu && navigator.gpu.requestAdapter) {
      navigator.gpu.requestAdapter().then((a) => {
        if (!a) return this.setState({ gpu: 'unavailable' }, this.pickTier);
        const info = (a.info && (a.info.vendor || a.info.description)) || '';
        this.setState({ gpu: 'available', gpuName: String(info).slice(0, 28) }, this.pickTier);
      }).catch(() => this.setState({ gpu: 'unavailable' }, this.pickTier));
    } else {
      this.setState({ gpu: 'unavailable' }, this.pickTier);
    }
    this.openDb().then((db) => this.load(db)).catch(() => {});
  }

  pickTier = () => {
    const s = this.state;
    this.setState({ tier: s.gpu === 'available' ? 'WEBGPU' : s.simd === 'available' ? 'WASM' : 'CPU' });
  };

  openDb() {
    return new Promise((res, rej) => {
      const r = indexedDB.open('kugguk-rcv', 1);
      r.onupgradeneeded = () => r.result.createObjectStore('clips');
      r.onsuccess = () => res(r.result);
      r.onerror = () => rej(r.error);
    });
  }

  store(blob) {
    return this.openDb().then((db) => new Promise((res) => {
      const tx = db.transaction('clips', 'readwrite');
      tx.objectStore('clips').put(blob, 'sample');
      tx.oncomplete = () => res();
    }));
  }

  load(db) {
    return new Promise((res) => {
      const tx = db.transaction('clips', 'readonly');
      const q = tx.objectStore('clips').get('sample');
      q.onsuccess = () => {
        if (!q.result) return res();
        this.decode(q.result).then(() => this.setState({ status: 'HELD LOCALLY' }));
        res();
      };
      q.onerror = () => res();
    });
  }

  decode(blob) {
    this.setState({ bytes: blob.size });
    return blob.arrayBuffer()
      .then((ab) => {
        this.ctx = this.ctx || new (window.AudioContext || window.webkitAudioContext)();
        return this.ctx.decodeAudioData(ab);
      })
      .then((buf) => { this.buf = buf; this.drawWave(buf); })
      .catch(() => {});
  }

  drawWave(buf) {
    const d = buf.getChannelData(0), N = 72, step = Math.floor(d.length / N);
    const wave = [];
    for (let i = 0; i < N; i++) {
      let peak = 0;
      for (let j = 0; j < step; j += 8) peak = Math.max(peak, Math.abs(d[i * step + j] || 0));
      wave.push({ h: Math.max(2, Math.round(peak * 96)) + 'px' });
    }
    this.setState({ wave });
  }

  record = () => {
    this.setState({ status: 'REQUESTING MIC' });
    navigator.mediaDevices.getUserMedia({ audio: true }).then((stream) => {
      const rec = new MediaRecorder(stream);
      const parts = [];
      rec.ondataavailable = (e) => parts.push(e.data);
      rec.onstop = () => {
        stream.getTracks().forEach((t) => t.stop());
        const blob = new Blob(parts, { type: rec.mimeType || 'audio/webm' });
        this.store(blob).then(() => this.decode(blob)).then(() => this.setState({ status: 'STORED OFFLINE', plays: 0, rate: 1 }));
      };
      rec.start();
      this.setState({ status: 'RECORDING 3s' });
      setTimeout(() => rec.state !== 'inactive' && rec.stop(), 3000);
    }).catch(() => this.setState({ status: 'MIC DENIED' }));
  };

  // Same kernel on every tier: resample + gain. WebGPU runs it as a compute
  // shader; the CPU path is the plain-JS floor.
  gpuKernel(input, rate, gain) {
    const dev = this.dev;
    const n = Math.floor(input.length / rate);
    const inBuf = dev.createBuffer({ size: input.byteLength, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST });
    dev.queue.writeBuffer(inBuf, 0, input);
    const outBuf = dev.createBuffer({ size: n * 4, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC });
    const readBuf = dev.createBuffer({ size: n * 4, usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ });
    const par = dev.createBuffer({ size: 16, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST });
    dev.queue.writeBuffer(par, 0, new Float32Array([rate, gain, input.length, n]));
    const mod = dev.createShaderModule({ code: `
      struct P { rate: f32, gain: f32, inLen: f32, outLen: f32 };
      @group(0) @binding(0) var<storage, read> src: array<f32>;
      @group(0) @binding(1) var<storage, read_write> dst: array<f32>;
      @group(0) @binding(2) var<uniform> p: P;
      @compute @workgroup_size(64)
      fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
        let i = gid.x;
        if (f32(i) >= p.outLen) { return; }
        let pos = f32(i) * p.rate;
        let i0 = u32(floor(pos));
        let f = pos - floor(pos);
        let a = src[i0];
        let b = src[min(i0 + 1u, u32(p.inLen) - 1u)];
        dst[i] = (a + (b - a) * f) * p.gain;
      }` });
    const pipe = dev.createComputePipeline({ layout: 'auto', compute: { module: mod, entryPoint: 'main' } });
    const bind = dev.createBindGroup({ layout: pipe.getBindGroupLayout(0), entries: [
      { binding: 0, resource: { buffer: inBuf } },
      { binding: 1, resource: { buffer: outBuf } },
      { binding: 2, resource: { buffer: par } }
    ] });
    const enc = dev.createCommandEncoder();
    const pass = enc.beginComputePass();
    pass.setPipeline(pipe); pass.setBindGroup(0, bind);
    pass.dispatchWorkgroups(Math.ceil(n / 64));
    pass.end();
    enc.copyBufferToBuffer(outBuf, 0, readBuf, 0, n * 4);
    dev.queue.submit([enc.finish()]);
    return readBuf.mapAsync(GPUMapMode.READ).then(() => {
      const out = new Float32Array(readBuf.getMappedRange().slice(0));
      readBuf.unmap();
      return out;
    });
  }

  cpuKernel(input, rate, gain) {
    const n = Math.floor(input.length / rate), out = new Float32Array(n);
    for (let i = 0; i < n; i++) {
      const pos = i * rate, i0 = Math.floor(pos), f = pos - i0;
      const a = input[i0] || 0, b = input[Math.min(i0 + 1, input.length - 1)] || 0;
      out[i] = (a + (b - a) * f) * gain;
    }
    return Promise.resolve(out);
  }

  play = () => {
    if (!this.buf) return this.setState({ status: 'NOTHING HELD' });
    this.ctx = this.ctx || new (window.AudioContext || window.webkitAudioContext)();
    const plays = this.state.plays + 1;
    // "adapt": each replay converges toward the target rate
    const rate = +(1 + (0.94 - 1) * (1 - Math.pow(0.6, plays))).toFixed(3);
    const src = this.buf.getChannelData(0);
    const useGpu = this.state.tier === 'WEBGPU';
    const run = () => (useGpu ? this.gpuKernel(src, rate, 1.08) : this.cpuKernel(src, rate, 1.08));
    const start = performance.now();
    const ensure = useGpu && !this.dev
      ? navigator.gpu.requestAdapter().then((a) => a.requestDevice()).then((d) => { this.dev = d; })
      : Promise.resolve();
    ensure.then(run).catch(() => this.cpuKernel(src, rate, 1.08)).then((out) => {
      const ab = this.ctx.createBuffer(1, out.length, this.buf.sampleRate);
      ab.copyToChannel(out, 0);
      const node = this.ctx.createBufferSource();
      node.buffer = ab; node.connect(this.ctx.destination); node.start();
      this.drawWave(ab);
      const ms = Math.round(performance.now() - start);
      this.setState({ plays, rate, status: `${useGpu ? 'WEBGPU' : 'CPU'} KERNEL ${ms}ms` });
    });
  };

  wipe = () => {
    this.openDb().then((db) => {
      const tx = db.transaction('clips', 'readwrite');
      tx.objectStore('clips').delete('sample');
      tx.oncomplete = () => { this.buf = null; this.setState({ status: 'WIPED', wave: [], bytes: 0, plays: 0, rate: 1 }); };
    });
  };

  renderVals() {
    const s = this.state;
    const mark = (v) => v === 'available' ? 'READY' : v === 'probing' ? 'PROBING' : 'UNAVAILABLE';
    return {
      tiers: [
        { name: 'WEBGPU', detail: 'compute shader over the sample buffer' + (s.gpuName ? ' · ' + s.gpuName : ''), status: mark(s.gpu) },
        { name: 'WASM', detail: 'SIMD kernel, worker threads if available', status: mark(s.simd) },
        { name: 'CPU', detail: 'plain JS over Float32Array — the floor', status: 'READY' }
      ],
      tierLabel: s.tier,
      cores: String(s.cores),
      status: s.status,
      plays: s.plays,
      rate: s.rate.toFixed(3) + '×',
      bytes: s.bytes ? (s.bytes / 1024).toFixed(1) + ' KB' : '0 KB',
      wave: s.wave,
      record: this.record, play: this.play, wipe: this.wipe
    };
  }
}
</script>
</body>
</html>