opensips-js 0.1.15 → 0.1.16

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
@@ -243,11 +243,64 @@ Also, there are next public fields on OpensipsJS instance:
243
243
  - `isDND: Boolean` - returns if the agent is in "Do not disturb" status
244
244
  - `isMuted: Boolean` - returns if the agent is muted
245
245
 
246
- ### Noise Reduction Options
246
+ ### Noise Reduction Options (VAD)
247
+
248
+ **Important**: Voice Activity Detection (VAD) is an **optional feature** that requires installing an additional peer dependency. It is **NOT compatible with React Native**.
249
+
250
+ #### For Web Applications (with VAD support)
251
+
252
+ Install the VAD library:
253
+ ```bash
254
+ npm install @ricky0123/vad-web
255
+ # or
256
+ yarn add @ricky0123/vad-web
257
+ ```
258
+
259
+ Then import and inject it in your configuration:
260
+ ```javascript
261
+ import OpenSIPSJS from 'opensips-js'
262
+ import * as VAD from '@ricky0123/vad-web'
263
+
264
+ const opensipsJS = new OpenSIPSJS({
265
+ configuration: {
266
+ // ... other configuration
267
+ noiseReductionOptions: {
268
+ mode: 'dynamic', // or 'enabled'
269
+ noiseThreshold: 0.004,
270
+ checkEveryMs: 500,
271
+ noiseCheckInterval: 2000
272
+ },
273
+ vadModule: VAD // Inject the VAD module
274
+ },
275
+ // ... rest of configuration
276
+ })
277
+ ```
278
+
279
+ #### For React Native Applications (VAD not supported)
280
+
281
+ Simply omit the VAD module and disable noise reduction:
282
+ ```javascript
283
+ import OpenSIPSJS from 'opensips-js'
284
+
285
+ const opensipsJS = new OpenSIPSJS({
286
+ configuration: {
287
+ // ... other configuration
288
+ noiseReductionOptions: {
289
+ mode: 'disabled' // or omit noiseReductionOptions entirely
290
+ }
291
+ // NO vadModule needed
292
+ },
293
+ // ... rest of configuration
294
+ })
295
+ ```
296
+
297
+ **See [VAD_USAGE.md](VAD_USAGE.md) and [EXAMPLES.md](EXAMPLES.md) for detailed usage examples.**
298
+
299
+ #### Configuration Parameters
247
300
 
248
301
  | Parameter | Type | Default | Description |
249
302
  |----------------------|----------------------------------|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
250
- | `mode` | `disabled \| enabled \| dynamic` | `disabled` | Noice reduction mode |
303
+ | `mode` | `disabled \| enabled \| dynamic` | `disabled` | Noise reduction mode. **Note**: `enabled` and `dynamic` modes require `vadModule` to be provided |
251
304
  | `vadConfig` | `Partial<RealTimeVADOptions>` | `{}` | VAD configuration |
252
305
  | `noiseThreshold` | `number` | `0.004` | Noise threshold |
253
306
  | `noiseCheckInterval` | `number` | `2000` | The interval, used to check if we need to disable/enable outgoing audio every N-milliseconds |
package/dist/index.d.ts CHANGED
@@ -78,7 +78,6 @@ declare class AudioModule {
78
78
  private MicVAD;
79
79
  managedAudioContext: ManagedAudioContext;
80
80
  constructor(context: OpenSIPSJS);
81
- private importVad;
82
81
  private processVADConfiguration;
83
82
  get sipOptions(): {
84
83
  mediaConstraints: {
@@ -980,6 +979,7 @@ declare type UAConfigurationExtended = UAConfiguration & {
980
979
  overrideUserAgent?: (userAgent: string) => string
981
980
  noiseReductionOptions?: NoiseReductionOptions
982
981
  onTransportCallback?: OnTransportCallback
982
+ vadModule?: VADModule
983
983
  }
984
984
 
985
985
  declare const UAConstructor: typeof UA;
@@ -1069,6 +1069,10 @@ declare interface UAExtendedInterface_2 extends UA {
1069
1069
 
1070
1070
  declare type updateRoomListener = (value: RoomChangeEmitType) => void
1071
1071
 
1072
+ declare interface VADModule {
1073
+ MicVAD: any
1074
+ }
1075
+
1072
1076
  declare interface VADOptions {
1073
1077
  model: 'v5' | 'legacy'
1074
1078
  positiveSpeechThreshold: number