@layercode/js-sdk 2.8.7 → 2.8.8

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.
@@ -5827,7 +5827,7 @@ class LayercodeClient {
5827
5827
  * @param {Object} options - Configuration options
5828
5828
  */
5829
5829
  constructor(options) {
5830
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
5830
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
5831
5831
  this.deviceId = null;
5832
5832
  this.options = {
5833
5833
  agentId: options.agentId,
@@ -5839,24 +5839,25 @@ class LayercodeClient {
5839
5839
  audioInput: (_d = options.audioInput) !== null && _d !== void 0 ? _d : true,
5840
5840
  audioInputChanged: (_e = options.audioInputChanged) !== null && _e !== void 0 ? _e : NOOP,
5841
5841
  audioOutput: (_f = options.audioOutput) !== null && _f !== void 0 ? _f : true,
5842
- audioOutputChanged: (_g = options.audioOutputChanged) !== null && _g !== void 0 ? _g : NOOP,
5843
- onConnect: (_h = options.onConnect) !== null && _h !== void 0 ? _h : NOOP,
5844
- onDisconnect: (_j = options.onDisconnect) !== null && _j !== void 0 ? _j : NOOP,
5845
- onError: (_k = options.onError) !== null && _k !== void 0 ? _k : NOOP,
5846
- onDeviceSwitched: (_l = options.onDeviceSwitched) !== null && _l !== void 0 ? _l : NOOP,
5847
- onDevicesChanged: (_m = options.onDevicesChanged) !== null && _m !== void 0 ? _m : NOOP,
5848
- onDataMessage: (_o = options.onDataMessage) !== null && _o !== void 0 ? _o : NOOP,
5849
- onMessage: (_p = options.onMessage) !== null && _p !== void 0 ? _p : NOOP,
5850
- onUserAmplitudeChange: (_q = options.onUserAmplitudeChange) !== null && _q !== void 0 ? _q : NOOP,
5851
- onAgentAmplitudeChange: (_r = options.onAgentAmplitudeChange) !== null && _r !== void 0 ? _r : NOOP,
5852
- onStatusChange: (_s = options.onStatusChange) !== null && _s !== void 0 ? _s : NOOP,
5853
- onUserIsSpeakingChange: (_t = options.onUserIsSpeakingChange) !== null && _t !== void 0 ? _t : NOOP,
5854
- onAgentSpeakingChange: (_u = options.onAgentSpeakingChange) !== null && _u !== void 0 ? _u : NOOP,
5855
- onMuteStateChange: (_v = options.onMuteStateChange) !== null && _v !== void 0 ? _v : NOOP,
5856
- enableAmplitudeMonitoring: (_w = options.enableAmplitudeMonitoring) !== null && _w !== void 0 ? _w : true,
5842
+ enableVAD: (_g = options.enableVAD) !== null && _g !== void 0 ? _g : true,
5843
+ audioOutputChanged: (_h = options.audioOutputChanged) !== null && _h !== void 0 ? _h : NOOP,
5844
+ onConnect: (_j = options.onConnect) !== null && _j !== void 0 ? _j : NOOP,
5845
+ onDisconnect: (_k = options.onDisconnect) !== null && _k !== void 0 ? _k : NOOP,
5846
+ onError: (_l = options.onError) !== null && _l !== void 0 ? _l : NOOP,
5847
+ onDeviceSwitched: (_m = options.onDeviceSwitched) !== null && _m !== void 0 ? _m : NOOP,
5848
+ onDevicesChanged: (_o = options.onDevicesChanged) !== null && _o !== void 0 ? _o : NOOP,
5849
+ onDataMessage: (_p = options.onDataMessage) !== null && _p !== void 0 ? _p : NOOP,
5850
+ onMessage: (_q = options.onMessage) !== null && _q !== void 0 ? _q : NOOP,
5851
+ onUserAmplitudeChange: (_r = options.onUserAmplitudeChange) !== null && _r !== void 0 ? _r : NOOP,
5852
+ onAgentAmplitudeChange: (_s = options.onAgentAmplitudeChange) !== null && _s !== void 0 ? _s : NOOP,
5853
+ onStatusChange: (_t = options.onStatusChange) !== null && _t !== void 0 ? _t : NOOP,
5854
+ onUserIsSpeakingChange: (_u = options.onUserIsSpeakingChange) !== null && _u !== void 0 ? _u : NOOP,
5855
+ onAgentSpeakingChange: (_v = options.onAgentSpeakingChange) !== null && _v !== void 0 ? _v : NOOP,
5856
+ onMuteStateChange: (_w = options.onMuteStateChange) !== null && _w !== void 0 ? _w : NOOP,
5857
+ enableAmplitudeMonitoring: (_x = options.enableAmplitudeMonitoring) !== null && _x !== void 0 ? _x : true,
5857
5858
  };
5858
- this.audioInput = (_x = options.audioInput) !== null && _x !== void 0 ? _x : true;
5859
- this.audioOutput = (_y = options.audioOutput) !== null && _y !== void 0 ? _y : true;
5859
+ this.audioInput = (_y = options.audioInput) !== null && _y !== void 0 ? _y : true;
5860
+ this.audioOutput = (_z = options.audioOutput) !== null && _z !== void 0 ? _z : true;
5860
5861
  this._emitAudioInput();
5861
5862
  this.AMPLITUDE_MONITORING_SAMPLE_RATE = 2;
5862
5863
  this._websocketUrl = DEFAULT_WS_URL;
@@ -5873,6 +5874,7 @@ class LayercodeClient {
5873
5874
  this.agentAudioAmplitude = 0;
5874
5875
  this.conversationId = this.options.conversationId;
5875
5876
  this.pushToTalkActive = false;
5877
+ this.enableVAD = (_0 = this.options.enableVAD) !== null && _0 !== void 0 ? _0 : true;
5876
5878
  this.pushToTalkEnabled = false;
5877
5879
  this.canInterrupt = false;
5878
5880
  this.userIsSpeaking = false;
@@ -5916,6 +5918,11 @@ class LayercodeClient {
5916
5918
  async _initializeVAD() {
5917
5919
  var _a;
5918
5920
  console.log('initializing VAD', { pushToTalkEnabled: this.pushToTalkEnabled, canInterrupt: this.canInterrupt, vadConfig: this.vadConfig });
5921
+ // sometimes users want to disable vad to reduce work on client side
5922
+ if (!this.enableVAD) {
5923
+ console.debug('Skipping VAD init: VAD disabled');
5924
+ return;
5925
+ }
5919
5926
  // If we're in push to talk mode or mute mode, we don't need to use the VAD model
5920
5927
  if (this.pushToTalkEnabled || !this._shouldCaptureUserAudio()) {
5921
5928
  console.debug('Skipping VAD init: audio input disabled or muted');