@layercode/js-sdk 1.0.18 → 1.0.19

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.
@@ -3507,6 +3507,7 @@ registerProcessor('audio_processor', AudioProcessor);
3507
3507
  this.pushToTalkEnabled = false;
3508
3508
  this.canInterrupt = false;
3509
3509
  this.userIsSpeaking = false;
3510
+ this.endUserTurn = false;
3510
3511
  this.recorderStarted = false;
3511
3512
  this.readySent = false;
3512
3513
  // Bind event handlers
@@ -3542,11 +3543,7 @@ registerProcessor('audio_processor', AudioProcessor);
3542
3543
  this.userIsSpeaking = false;
3543
3544
  },
3544
3545
  onSpeechEnd: () => {
3545
- this.userIsSpeaking = false;
3546
- this._wsSend({
3547
- type: 'vad_events',
3548
- event: 'vad_end',
3549
- });
3546
+ this.endUserTurn = true; // Set flag to indicate that the user turn has ended, so we can send a vad_end event to the server
3550
3547
  },
3551
3548
  })
3552
3549
  .then((vad) => {
@@ -3722,6 +3719,14 @@ registerProcessor('audio_processor', AudioProcessor);
3722
3719
  type: 'client.audio',
3723
3720
  content: base64,
3724
3721
  });
3722
+ if (this.endUserTurn) {
3723
+ this.endUserTurn = false;
3724
+ this.userIsSpeaking = false; // Reset userIsSpeaking to false so we don't send any more audio to the server
3725
+ this._wsSend({
3726
+ type: 'vad_events',
3727
+ event: 'vad_end',
3728
+ });
3729
+ }
3725
3730
  }
3726
3731
  }
3727
3732
  catch (error) {