@gjsify/vad 0.64.26-next.312 → 0.64.27

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/lib/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{_resetVadBackendCache as e,createSherpaVadEngine as t,describeVadBackend as n,hasVadBackend as r,loadVadBackend as i,reportVadBackendOnce as a}from"./backend.js";import{createFakeVadEngine as o}from"./fake-vad.js";import{DEFAULT_VAD_MODEL as s,VAD_MODELS as c,findVadModel as l,requireVadModel as u}from"./model-manifest.js";import{available as d,install as f,installedModels as p,listModels as m,modelCacheDir as h,modelPath as g,resolveModel as _,uninstall as v}from"./models.js";import{inferFormat as y,toFloatSamples as b}from"./pcm.js";import{VoiceActivityDetector as x,createVad as S}from"./vad.js";export{s as DEFAULT_VAD_MODEL,c as VAD_MODELS,x as VoiceActivityDetector,e as _resetVadBackendCache,d as available,o as createFakeVadEngine,t as createSherpaVadEngine,S as createVad,n as describeVadBackend,l as findVadModel,r as hasVadBackend,y as inferFormat,f as install,p as installedModels,m as listModels,i as loadVadBackend,h as modelCacheDir,g as modelPath,a as reportVadBackendOnce,u as requireVadModel,_ as resolveModel,b as toFloatSamples,v as uninstall};
1
+ import{_resetVadBackendCache as e,createSherpaVadEngine as t,describeVadBackend as n,hasVadBackend as r,loadVadBackend as i,reportVadBackendOnce as a}from"./backend.js";import{createFakeVadEngine as o}from"./fake-vad.js";import{DEFAULT_VAD_MODEL as s,VAD_MODELS as c,findVadModel as l,requireVadModel as u}from"./model-manifest.js";import{available as d,install as f,installedModels as p,listModels as m,modelCacheDir as h,modelDir as g,resolveModel as _,uninstall as v}from"./models.js";import{inferFormat as y,toFloatSamples as b}from"./pcm.js";import{VoiceActivityDetector as x,createVad as S}from"./vad.js";export{s as DEFAULT_VAD_MODEL,c as VAD_MODELS,x as VoiceActivityDetector,e as _resetVadBackendCache,d as available,o as createFakeVadEngine,t as createSherpaVadEngine,S as createVad,n as describeVadBackend,l as findVadModel,r as hasVadBackend,y as inferFormat,f as install,p as installedModels,m as listModels,i as loadVadBackend,h as modelCacheDir,g as modelDir,a as reportVadBackendOnce,u as requireVadModel,_ as resolveModel,b as toFloatSamples,v as uninstall};
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";const e=`silero-v5`,t=`https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models`,n=[{id:`silero-v5`,file:`silero_vad_v5.onnx`,url:`${t}/silero_vad_v5.onnx`,bytes:2313101,sha256:`6b99cbfd39246b6706f98ec13c7c50c6b299181f2474fa05cbc8046acc274396`,license:`MIT`,redistributable:!0,sampleRate:16e3,windowSize:512,description:`Silero VAD v5 (2.2 MiB) — the default. Takes input/state/sr; 16 kHz, 512-sample windows.`},{id:`silero-v4`,file:`silero_vad.onnx`,url:`${t}/silero_vad.onnx`,bytes:643854,sha256:`9e2449e1087496d8d4caba907f23e0bd3f78d91fa552479bb9c23ac09cbb1fd6`,license:`MIT`,redistributable:!0,sampleRate:16e3,windowSize:512,description:`Silero VAD v4 (0.6 MiB) — smaller and older. Only its 16 kHz branch is covered here.`}];function findVadModel(t=e){return n.find(e=>e.id===t)}function requireVadModel(t=e){let r=findVadModel(t);if(r===void 0)throw RangeError(`Unknown VAD model '${t}' — known ids: ${n.map(e=>e.id).join(`, `)}`);return r}export{e as DEFAULT_VAD_MODEL,n as VAD_MODELS,findVadModel,requireVadModel};
1
+ import"./_virtual/_rolldown/runtime.js";const e=`silero-v5`,t=`https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models`,n=[{id:`silero-v5`,files:[{file:`silero_vad_v5.onnx`,url:`${t}/silero_vad_v5.onnx`,bytes:2313101,sha256:`6b99cbfd39246b6706f98ec13c7c50c6b299181f2474fa05cbc8046acc274396`}],license:`MIT`,redistributable:!0,sampleRate:16e3,windowSize:512,description:`Silero VAD v5 (2.2 MiB) — the default. Takes input/state/sr; 16 kHz, 512-sample windows.`},{id:`silero-v4`,files:[{file:`silero_vad.onnx`,url:`${t}/silero_vad.onnx`,bytes:643854,sha256:`9e2449e1087496d8d4caba907f23e0bd3f78d91fa552479bb9c23ac09cbb1fd6`}],license:`MIT`,redistributable:!0,sampleRate:16e3,windowSize:512,description:`Silero VAD v4 (0.6 MiB) — smaller and older. Only its 16 kHz branch is covered here.`}];function findVadModel(t=e){return n.find(e=>e.id===t)}function requireVadModel(t=e){let r=findVadModel(t);if(r===void 0)throw RangeError(`Unknown VAD model '${t}' — known ids: ${n.map(e=>e.id).join(`, `)}`);return r}export{e as DEFAULT_VAD_MODEL,n as VAD_MODELS,findVadModel,requireVadModel};
package/lib/esm/models.js CHANGED
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{hasVadBackend as e}from"./backend.js";import{DEFAULT_VAD_MODEL as t,VAD_MODELS as n}from"./model-manifest.js";import{join as r}from"node:path";import{ModelStore as i,userCacheDir as a}from"@gjsify/model-store";const o=new i({capability:`speech`,models:n,defaultModel:t,legacyDirs:()=>[r(a(),`gjsify`,`speech-models`)]});function modelCacheDir(){return o.cacheDir}function modelPath(e=t){return o.cachePath(e)}function available(n=t){return o.require(n),e()?o.availability(n):`unavailable`}function listModels(){return n.map(e=>({entry:e,availability:available(e.id)}))}function installedModels(){return o.installed()}function install(n=t,r={}){let i;try{i=o.require(n)}catch(e){return Promise.reject(e)}if(!e())return Promise.reject(Error(`install('${i.id}'): no native VAD engine on this host, so a model would be unusable — gate on available() and show describeVadBackend() instead.`));let{onProgress:a}=r;return o.install(i.id,{signal:r.signal,force:r.force,fetch:r.fetchImpl,monitor:a===void 0?void 0:e=>e.addEventListener(`downloadprogress`,e=>{let{receivedBytes:t,totalBytes:n}=e;a({modelId:i.id,received:t,total:n})})})}function uninstall(e=t){o.require(e);try{return o.uninstall(e)}catch{return!1}}function resolveModel(e=t){if(e.includes(`/`)||e.includes(`\\`))return e;let n=o.require(e),r=o.locate(n.id);if(r===void 0)throw Error(`VAD model '${n.id}' is not cached (${o.cachePath(n.id)}) — await install('${n.id}') first, or pass a path to a model file. ${n.bytes} bytes from ${n.url}.`);return r.path}export{available,install,installedModels,listModels,modelCacheDir,modelPath,resolveModel,uninstall};
1
+ import"./_virtual/_rolldown/runtime.js";import{hasVadBackend as e}from"./backend.js";import{DEFAULT_VAD_MODEL as t,VAD_MODELS as n}from"./model-manifest.js";import{join as r}from"node:path";import{ModelStore as i,userCacheDir as a}from"@gjsify/model-store";const o=new i({capability:`speech`,models:n,defaultModel:t,legacyDirs:()=>[r(a(),`gjsify`,`speech-models`)]});function modelCacheDir(){return o.cacheDir}function modelDir(e=t){return o.cachePath(e)}function available(n=t){return o.require(n),e()?o.availability(n):`unavailable`}function listModels(){return n.map(e=>({entry:e,availability:available(e.id)}))}function installedModels(){return o.installed()}function install(n=t,r={}){let i;try{i=o.require(n)}catch(e){return Promise.reject(e)}if(!e())return Promise.reject(Error(`install('${i.id}'): no native VAD engine on this host, so a model would be unusable — gate on available() and show describeVadBackend() instead.`));let{onProgress:a}=r;return o.install(i.id,{signal:r.signal,force:r.force,fetch:r.fetchImpl,monitor:a===void 0?void 0:e=>e.addEventListener(`downloadprogress`,e=>{let{receivedBytes:t,totalBytes:n}=e;a({modelId:i.id,received:t,total:n})})}).then(e=>e.files[i.files[0].file])}function uninstall(e=t){o.require(e);try{return o.uninstall(e)}catch{return!1}}function resolveModel(e=t){if(e.includes(`/`)||e.includes(`\\`))return e;let n=o.require(e),r=o.locate(n.id);if(r===void 0){let e=n.files.reduce((e,t)=>e+t.bytes,0);throw Error(`VAD model '${n.id}' is not cached (${o.cachePath(n.id)}) — await install('${n.id}') first, or pass a directory containing a model file. ${e} bytes from ${n.files[0].url}.`)}return r.files[n.files[0].file]}export{available,install,installedModels,listModels,modelCacheDir,modelDir,resolveModel,uninstall};
@@ -1,6 +1,6 @@
1
1
  export { createVad, VoiceActivityDetector } from './vad.js';
2
2
  export type { SpeechEndEvent, SpeechStartEvent, VadEvent, VadOptions } from './vad.js';
3
- export { available, install, installedModels, listModels, modelCacheDir, modelPath, resolveModel, uninstall, } from './models.js';
3
+ export { available, install, installedModels, listModels, modelCacheDir, modelDir, resolveModel, uninstall, } from './models.js';
4
4
  export type { InstallOptions, InstallProgress, VadModelAvailability } from './models.js';
5
5
  export { DEFAULT_VAD_MODEL, findVadModel, requireVadModel, VAD_MODELS } from './model-manifest.js';
6
6
  export type { VadModelEntry } from './model-manifest.js';
@@ -3,9 +3,9 @@ import { type VadModelEntry } from './model-manifest.js';
3
3
  /**
4
4
  * What `available()` answers, as the Web Speech on-device additions spell it:
5
5
  *
6
- * • `available` — the file is cached and verified-by-size; use it now.
6
+ * • `available` — all files are cached and verified-by-size; use it now.
7
7
  * • `downloading` — an `install()` for this id is in flight in this process.
8
- * • `downloadable` — the engine is here, the file is not; `install()` fetches it.
8
+ * • `downloadable` — the engine is here, the files are not; `install()` fetches them.
9
9
  * • `unavailable` — no native engine on this host, so no model helps.
10
10
  */
11
11
  export type VadModelAvailability = ModelAvailability;
@@ -13,7 +13,7 @@ export interface InstallProgress {
13
13
  readonly modelId: string;
14
14
  /** Bytes written so far. */
15
15
  readonly received: number;
16
- /** The manifest's size for this model. */
16
+ /** The manifest's total size for this model. */
17
17
  readonly total: number;
18
18
  }
19
19
  export interface InstallOptions {
@@ -23,13 +23,13 @@ export interface InstallOptions {
23
23
  signal?: AbortSignal;
24
24
  /** Override the global `fetch`. Tests only. */
25
25
  fetchImpl?: FetchLike;
26
- /** Re-fetch and overwrite a cached file instead of returning it. */
26
+ /** Re-fetch and overwrite cached files instead of returning them. */
27
27
  force?: boolean;
28
28
  }
29
29
  /** `<user cache>/gjsify/models/speech` — shared with the other ADR 0127 packages. */
30
30
  export declare function modelCacheDir(): string;
31
- /** Where `id` is cached, whether or not it exists yet. */
32
- export declare function modelPath(id?: string): string;
31
+ /** Directory where `id` is cached, whether or not it exists yet. */
32
+ export declare function modelDir(id?: string): string;
33
33
  /**
34
34
  * Whether this host can run a VAD with `id`, and what it would take.
35
35
  *
@@ -46,24 +46,24 @@ export declare function listModels(): {
46
46
  /** Cached model ids, in manifest order. */
47
47
  export declare function installedModels(): string[];
48
48
  /**
49
- * Make `id` usable, fetching it if it is not cached. Resolves to its path.
49
+ * Make `id` usable, fetching it if it is not cached. Resolves to its model file path.
50
50
  *
51
- * Idempotent and safe to call concurrently: a cached file returns immediately
51
+ * Idempotent and safe to call concurrently: a cached model returns immediately
52
52
  * and two overlapping calls share one download. Rejects when the host has no
53
- * native engine — `install()` is a commitment to a 2.2 MiB fetch, so it does
54
- * not quietly succeed into a state where `createVad()` still cannot run.
53
+ * native engine — `install()` is a commitment to a fetch, so it does not
54
+ * quietly succeed into a state where `createVad()` still cannot run.
55
55
  *
56
56
  * EVERY failure is a rejection, including an unknown id: a function that
57
57
  * returns a promise and sometimes throws before it has to be awaited needs two
58
58
  * error paths at every call site.
59
59
  */
60
60
  export declare function install(id?: string, options?: InstallOptions): Promise<string>;
61
- /** Delete the cached file for `id`. `false` when there was nothing to delete. */
61
+ /** Delete the cached files for `id`. `false` when there was nothing to delete. */
62
62
  export declare function uninstall(id?: string): boolean;
63
63
  /**
64
64
  * Resolve `VadOptions.model` to a path on disk.
65
65
  *
66
- * A value containing a path separator is taken as a path and used as given —
66
+ * A value containing a path separator is taken as a directory and used as given —
67
67
  * that is how a caller points at a model this manifest does not know. Anything
68
68
  * else is a manifest id, and it must already be cached: resolving must not
69
69
  * start a download behind a synchronous constructor.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/vad",
3
- "version": "0.64.26-next.312",
3
+ "version": "0.64.27",
4
4
  "description": "Voice activity detection for GJS: Silero on sherpa-onnx, reporting when speech starts and when a stretch of speech has ended after 300 ms of silence. Takes PCM from @gjsify/media-capture or any async iterable of chunks, and downloads its model on first use instead of bundling one.",
5
5
  "type": "module",
6
6
  "module": "lib/esm/index.js",
@@ -35,17 +35,17 @@
35
35
  "speech"
36
36
  ],
37
37
  "dependencies": {
38
- "@gjsify/model-store": "0.64.26-next.312",
39
- "@gjsify/path": "0.64.26-next.312",
40
- "@gjsify/sherpa-native": "0.64.26-next.312",
41
- "@gjsify/utils": "0.64.26-next.312"
38
+ "@gjsify/model-store": "^0.64.27",
39
+ "@gjsify/path": "^0.64.27",
40
+ "@gjsify/sherpa-native": "^0.64.27",
41
+ "@gjsify/utils": "^0.64.27"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@girs/gio-2.0": "5.4.0",
45
45
  "@girs/gjs": "5.4.0",
46
46
  "@girs/glib-2.0": "5.4.0",
47
- "@gjsify/cli": "0.64.26-next.312",
48
- "@gjsify/unit": "0.64.26-next.312",
47
+ "@gjsify/cli": "^0.64.27",
48
+ "@gjsify/unit": "^0.64.27",
49
49
  "@types/node": "^25.9.2",
50
50
  "typescript": "^6.0.3"
51
51
  },
@@ -77,6 +77,5 @@
77
77
  "bugs": {
78
78
  "url": "https://github.com/gjsify/gjsify/issues"
79
79
  },
80
- "homepage": "https://github.com/gjsify/gjsify/tree/main/packages/web/vad#readme",
81
- "gitHead": "75fa6155a8f1fa0f7e5d70c43418ae41ecac8c0e"
80
+ "homepage": "https://github.com/gjsify/gjsify/tree/main/packages/web/vad#readme"
82
81
  }