@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.
@@ -3501,6 +3501,7 @@ class LayercodeClient {
3501
3501
  this.pushToTalkEnabled = false;
3502
3502
  this.canInterrupt = false;
3503
3503
  this.userIsSpeaking = false;
3504
+ this.endUserTurn = false;
3504
3505
  this.recorderStarted = false;
3505
3506
  this.readySent = false;
3506
3507
  // Bind event handlers
@@ -3536,11 +3537,7 @@ class LayercodeClient {
3536
3537
  this.userIsSpeaking = false;
3537
3538
  },
3538
3539
  onSpeechEnd: () => {
3539
- this.userIsSpeaking = false;
3540
- this._wsSend({
3541
- type: 'vad_events',
3542
- event: 'vad_end',
3543
- });
3540
+ this.endUserTurn = true; // Set flag to indicate that the user turn has ended, so we can send a vad_end event to the server
3544
3541
  },
3545
3542
  })
3546
3543
  .then((vad) => {
@@ -3716,6 +3713,14 @@ class LayercodeClient {
3716
3713
  type: 'client.audio',
3717
3714
  content: base64,
3718
3715
  });
3716
+ if (this.endUserTurn) {
3717
+ this.endUserTurn = false;
3718
+ this.userIsSpeaking = false; // Reset userIsSpeaking to false so we don't send any more audio to the server
3719
+ this._wsSend({
3720
+ type: 'vad_events',
3721
+ event: 'vad_end',
3722
+ });
3723
+ }
3719
3724
  }
3720
3725
  }
3721
3726
  catch (error) {