@hyperwindmill/caretaker-cli 0.30.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/web/voice_backend.d.ts +4 -0
- package/dist/cli/web/voice_backend.d.ts.map +1 -1
- package/dist/cli/web/voice_backend.js +14 -3
- package/dist/cli/web/voice_builtin.d.ts.map +1 -1
- package/dist/cli/web/voice_builtin.js +32 -13
- package/dist/cli/web/voice_proxy.d.ts +3 -0
- package/dist/cli/web/voice_proxy.d.ts.map +1 -1
- package/dist/cli/web/voice_proxy.js +28 -3
- package/dist/harness/tools/builtin/set_workspace.d.ts.map +1 -1
- package/dist/harness/tools/builtin/set_workspace.js +26 -4
- package/dist/session/store.d.ts +2 -2
- package/dist/session/store.d.ts.map +1 -1
- package/dist/session/store.js +5 -2
- package/dist/session/types.d.ts +2 -1
- package/dist/session/types.d.ts.map +1 -1
- package/dist/store/db.d.ts.map +1 -1
- package/dist/store/db.js +3 -1
- package/dist/voice/pocket/install.d.ts +16 -2
- package/dist/voice/pocket/install.d.ts.map +1 -1
- package/dist/voice/pocket/install.js +59 -5
- package/dist/voice/pronunciation.d.ts.map +1 -1
- package/dist/voice/pronunciation.js +3 -0
- package/dist/voice/whisper/catalog.d.ts +15 -0
- package/dist/voice/whisper/catalog.d.ts.map +1 -0
- package/dist/voice/whisper/catalog.js +53 -0
- package/dist/voice/whisper/decoder.d.ts +3 -0
- package/dist/voice/whisper/decoder.d.ts.map +1 -0
- package/dist/voice/whisper/decoder.js +48 -0
- package/dist/voice/whisper/engine.d.ts +8 -0
- package/dist/voice/whisper/engine.d.ts.map +1 -0
- package/dist/voice/whisper/engine.js +77 -0
- package/dist/voice/whisper/features.d.ts +10 -0
- package/dist/voice/whisper/features.d.ts.map +1 -0
- package/dist/voice/whisper/features.js +149 -0
- package/dist/voice/whisper/inference.d.ts +17 -0
- package/dist/voice/whisper/inference.d.ts.map +1 -0
- package/dist/voice/whisper/inference.js +257 -0
- package/dist/voice/whisper/wav.d.ts +5 -0
- package/dist/voice/whisper/wav.d.ts.map +1 -0
- package/dist/voice/whisper/wav.js +48 -0
- package/dist/webview/standalone.js +914 -687
- package/dist/webview/standalone.js.map +4 -4
- package/package.json +3 -3
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** Parse a RIFF/WAVE file that is exactly what the Whisper engine consumes:
|
|
2
|
+
* 16 kHz, mono, 16-bit integer PCM. Anything else throws a readable Error —
|
|
3
|
+
* the server has no resampler and must never feed garbage to the model. */
|
|
4
|
+
export function parseWav16kMono(buf) {
|
|
5
|
+
if (buf.length < 12)
|
|
6
|
+
throw new Error('Not a WAV file: too short.');
|
|
7
|
+
const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
8
|
+
const tag = (o) => String.fromCharCode(buf[o], buf[o + 1], buf[o + 2], buf[o + 3]);
|
|
9
|
+
if (tag(0) !== 'RIFF' || tag(8) !== 'WAVE')
|
|
10
|
+
throw new Error('Not a WAV file: missing RIFF/WAVE header.');
|
|
11
|
+
let fmt = null;
|
|
12
|
+
let pos = 12;
|
|
13
|
+
while (pos + 8 <= buf.length) {
|
|
14
|
+
const id = tag(pos);
|
|
15
|
+
const size = dv.getUint32(pos + 4, true);
|
|
16
|
+
const body = pos + 8;
|
|
17
|
+
if (id === 'fmt ') {
|
|
18
|
+
if (size < 16 || body + 16 > buf.length)
|
|
19
|
+
throw new Error('Invalid WAV: truncated fmt chunk.');
|
|
20
|
+
fmt = {
|
|
21
|
+
format: dv.getUint16(body, true),
|
|
22
|
+
channels: dv.getUint16(body + 2, true),
|
|
23
|
+
rate: dv.getUint32(body + 4, true),
|
|
24
|
+
bits: dv.getUint16(body + 14, true),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
else if (id === 'data') {
|
|
28
|
+
if (!fmt)
|
|
29
|
+
throw new Error('Invalid WAV: data chunk before fmt chunk.');
|
|
30
|
+
if (fmt.format !== 1)
|
|
31
|
+
throw new Error(`Unsupported WAV: expected integer PCM, got format ${fmt.format}.`);
|
|
32
|
+
if (fmt.bits !== 16)
|
|
33
|
+
throw new Error(`Unsupported WAV: expected 16-bit samples, got ${fmt.bits}-bit.`);
|
|
34
|
+
if (fmt.channels !== 1)
|
|
35
|
+
throw new Error(`Unsupported WAV: expected mono, got ${fmt.channels} channels.`);
|
|
36
|
+
if (fmt.rate !== 16000)
|
|
37
|
+
throw new Error(`Unsupported WAV: expected 16000 Hz, got ${fmt.rate} Hz.`);
|
|
38
|
+
const end = Math.min(body + size, buf.length);
|
|
39
|
+
const n = Math.floor((end - body) / 2);
|
|
40
|
+
const out = new Float32Array(n);
|
|
41
|
+
for (let i = 0; i < n; i++)
|
|
42
|
+
out[i] = dv.getInt16(body + i * 2, true) / 32768;
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
pos = body + size + (size % 2);
|
|
46
|
+
}
|
|
47
|
+
throw new Error(fmt ? 'Invalid WAV: no data chunk.' : 'Invalid WAV: no fmt chunk.');
|
|
48
|
+
}
|