Fix #29 by removing compression altogether

This commit is contained in:
msqr1
2025-04-03 19:42:02 -07:00
parent c64ae47ac7
commit 006199d103
11 changed files with 43 additions and 37 deletions

View File

@@ -48,19 +48,20 @@ class CommonModel extends EventTarget {
resolve(mdl)
}
else reject(ev.detail)
}, { once: true })
}, { once: true });
});
let cache = await caches.open('Vosklet');
let req = (await cache.keys(storepath, { ignoreSearch: true }))[0]
let tar, res;
let req = (await cache.keys(storepath, { ignoreSearch: true }))[0];
let res;
if (typeof req == 'undefined' || req.url.split('?')[1] != id) {
// Caching already handled explicitly
res = await fetch(url, { cache: 'no-store' });
if (!res.ok) throw 'Unable to fetch model, status: ' + res.status;
await cache.put(storepath + '?' + id, res.clone());
await cache.put(storepath + '?' + id, new Response(res.body.pipeThrough(new DecompressionStream('gzip'))));
}
else res = await cache.match(req)
tar = await new Response(res.body.pipeThrough(new DecompressionStream('gzip'))).arrayBuffer();
let tar = await res.arrayBuffer();
let tarStart = _malloc(tar.byteLength);
HEAPU8.set(new Uint8Array(tar), tarStart);
mdl.obj = new Module['CommonModel'](objs.length - 1, normalMdl, tarStart, tar.byteLength);
@@ -70,6 +71,7 @@ class CommonModel extends EventTarget {
class Recognizer extends EventTarget {
constructor() {
super();
// Closure workaround to prevent acceptWaveform from getting removed
this['acceptWaveform'] = audioData => {
let start = _malloc(audioData.length * 4);