opensips-js 0.1.35 → 0.1.36

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/README.md CHANGED
@@ -291,6 +291,48 @@ opensipsJS.audio.setVADConfiguration({
291
291
  })
292
292
  ```
293
293
 
294
+ #### For Chrome MV3 Extensions
295
+
296
+ Chrome Manifest V3 extensions block dynamic imports from external sources at the browser level. To use VAD in a Chrome MV3 extension, you must bundle the VAD assets locally.
297
+
298
+ **1. Copy required files to your extension:**
299
+
300
+ From `node_modules/@ricky0123/vad-web/dist/`:
301
+ - `silero_vad_legacy.onnx`
302
+ - `silero_vad_v5.onnx`
303
+ - `vad.worklet.bundle.min.js`
304
+
305
+ From `node_modules/onnxruntime-web/dist/`:
306
+ - `ort-wasm-simd-threaded.mjs`
307
+ - `ort-wasm-simd-threaded.wasm`
308
+
309
+ Place them in your extension directory (e.g., `assets/vad/` and `assets/onnx/`).
310
+
311
+ **Note**: The exact ONNX files needed may vary depending on browser capabilities. If you encounter loading errors, you may also need `ort-wasm-simd-threaded.jsep.wasm` or other variants from the `onnxruntime-web/dist/` folder.
312
+
313
+ **2. Configure OpenSIPSJS with local paths:**
314
+
315
+ ```javascript
316
+ import OpenSIPSJS from 'opensips-js'
317
+ import * as VAD from '@ricky0123/vad-web'
318
+
319
+ const opensipsJS = new OpenSIPSJS({
320
+ configuration: {
321
+ // ... other configuration
322
+ noiseReductionOptions: {
323
+ mode: 'dynamic',
324
+ vadModule: VAD,
325
+ // Point to locally bundled assets
326
+ baseAssetPath: browser.runtime.getURL('assets/vad/'),
327
+ onnxWASMBasePath: browser.runtime.getURL('assets/onnx/')
328
+ }
329
+ },
330
+ // ... rest of configuration
331
+ })
332
+ ```
333
+
334
+ **Note**: If your extension page is opened via `browser.windows.create()` or similar (extension's own context), you don't need `web_accessible_resources`. The extension can access its bundled files directly.
335
+
294
336
  #### For React Native Applications (VAD not supported)
295
337
 
296
338
  Simply omit the VAD module and disable noise reduction:
@@ -313,13 +355,15 @@ const opensipsJS = new OpenSIPSJS({
313
355
 
314
356
  #### Configuration Parameters
315
357
 
316
- | Parameter | Type | Default | Description |
317
- |----------------------|----------------------------------|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
318
- | `mode` | `disabled \| enabled \| dynamic` | `disabled` | Noise reduction mode. **Note**: `enabled` and `dynamic` modes require `vadModule` to be provided |
319
- | `vadConfig` | `Partial<RealTimeVADOptions>` | `{}` | VAD configuration |
320
- | `noiseThreshold` | `number` | `0.004` | Noise threshold |
321
- | `noiseCheckInterval` | `number` | `2000` | The interval, used to check if we need to disable/enable outgoing audio every N-milliseconds |
322
- | `checkEveryMs` | `number` | `500` | The interval, used inside noiseCheckInterval loop, checks current noise state every N-milliseconds, to define the average noise level. Then on every noiseCheckInterval iteration, the values getting on checkEveryMs will be summed, then divided by it's number and compared to noiseThreshold |
358
+ | Parameter | Type | Default | Description |
359
+ |----------------------|----------------------------------|----------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
360
+ | `mode` | `disabled \| enabled \| dynamic` | `disabled` | Noise reduction mode. **Note**: `enabled` and `dynamic` modes require `vadModule` to be provided |
361
+ | `vadConfig` | `Partial<RealTimeVADOptions>` | `{}` | VAD configuration |
362
+ | `noiseThreshold` | `number` | `0.004` | Noise threshold |
363
+ | `noiseCheckInterval` | `number` | `2000` | The interval, used to check if we need to disable/enable outgoing audio every N-milliseconds |
364
+ | `checkEveryMs` | `number` | `500` | The interval, used inside noiseCheckInterval loop, checks current noise state every N-milliseconds, to define the average noise level. Then on every noiseCheckInterval iteration, the values getting on checkEveryMs will be summed, then divided by it's number and compared to noiseThreshold |
365
+ | `baseAssetPath` | `string` | `https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.28/dist/` | Base path for VAD web assets. For Chrome MV3 extensions, use local bundled path via `browser.runtime.getURL()` |
366
+ | `onnxWASMBasePath` | `string` | `https://cdn.jsdelivr.net/npm/onnxruntime-web@1.22.0/dist/` | Base path for ONNX runtime WASM files. For Chrome MV3 extensions, use local bundled path via `browser.runtime.getURL()` |
323
367
 
324
368
  ## MSRP
325
369
 
package/dist/index.d.ts CHANGED
@@ -829,6 +829,18 @@ declare interface NoiseReductionOptions {
829
829
  noiseThreshold?: number
830
830
  checkEveryMs?: number
831
831
  noiseCheckInterval?: number
832
+ /**
833
+ * Base path for VAD web assets (silero model, worklet processor, etc.)
834
+ * Default: 'https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.28/dist/'
835
+ * For Chrome MV3 extensions, bundle assets locally and provide local path (e.g., 'chrome-extension://<id>/vad/')
836
+ */
837
+ baseAssetPath?: string
838
+ /**
839
+ * Base path for ONNX runtime WASM files
840
+ * Default: 'https://cdn.jsdelivr.net/npm/onnxruntime-web@1.22.0/dist/'
841
+ * For Chrome MV3 extensions, bundle ONNX WASM files locally and provide local path
842
+ */
843
+ onnxWASMBasePath?: string
832
844
  }
833
845
 
834
846
  declare type NoiseReductionOptionsWithoutVadModule = Omit<NoiseReductionOptions, 'vadModule'>