@layercode/js-sdk 1.0.13 → 1.0.14
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.
|
@@ -3475,6 +3475,7 @@ class LayercodeClient {
|
|
|
3475
3475
|
authorizeSessionEndpoint: options.authorizeSessionEndpoint,
|
|
3476
3476
|
metadata: options.metadata || {},
|
|
3477
3477
|
vadEnabled: options.vadEnabled || true,
|
|
3478
|
+
vadResumeDelay: options.vadResumeDelay || 500,
|
|
3478
3479
|
onConnect: options.onConnect || (() => { }),
|
|
3479
3480
|
onDisconnect: options.onDisconnect || (() => { }),
|
|
3480
3481
|
onError: options.onError || (() => { }),
|
|
@@ -3497,10 +3498,10 @@ class LayercodeClient {
|
|
|
3497
3498
|
model: 'v5',
|
|
3498
3499
|
// baseAssetPath: '/', // Use if bundling model locally
|
|
3499
3500
|
// onnxWASMBasePath: '/', // Use if bundling model locally
|
|
3500
|
-
positiveSpeechThreshold: 0.
|
|
3501
|
-
negativeSpeechThreshold: 0.
|
|
3502
|
-
redemptionFrames:
|
|
3503
|
-
minSpeechFrames:
|
|
3501
|
+
positiveSpeechThreshold: 0.3,
|
|
3502
|
+
negativeSpeechThreshold: 0.2,
|
|
3503
|
+
redemptionFrames: 25, // Number of frames of silence before onVADMisfire or onSpeechEnd is called. Effectively a delay before restarting.
|
|
3504
|
+
minSpeechFrames: 15,
|
|
3504
3505
|
preSpeechPadFrames: 0,
|
|
3505
3506
|
onSpeechStart: () => {
|
|
3506
3507
|
// Only pause agent audio if it's currently playing
|
|
@@ -3511,23 +3512,35 @@ class LayercodeClient {
|
|
|
3511
3512
|
}
|
|
3512
3513
|
else {
|
|
3513
3514
|
console.log('onSpeechStart: WavPlayer is not playing, VAD will not pause.');
|
|
3514
|
-
this.vadPausedPlayer = false;
|
|
3515
3515
|
}
|
|
3516
3516
|
},
|
|
3517
3517
|
onVADMisfire: () => {
|
|
3518
|
-
// If the speech detected was for less than minSpeechFrames, this is called instead of onSpeechEnd, and we should resume the assistant audio as it was a false interruption
|
|
3518
|
+
// If the speech detected was for less than minSpeechFrames, this is called instead of onSpeechEnd, and we should resume the assistant audio as it was a false interruption. We include a configurable delay so the assistant isn't too quick to start speaking again.
|
|
3519
3519
|
if (this.vadPausedPlayer) {
|
|
3520
|
-
console.log('
|
|
3520
|
+
console.log('onSpeechEnd: VAD paused the player, resuming');
|
|
3521
3521
|
this.wavPlayer.play();
|
|
3522
3522
|
this.vadPausedPlayer = false; // Reset flag
|
|
3523
|
+
// Option to extend delay in the case where the transcriber takes longer to detect a new turn
|
|
3524
|
+
// console.log('onVADMisfire: VAD paused the player, resuming in ' + this.options.vadResumeDelay + 'ms');
|
|
3525
|
+
// // Add configurable delay before resuming playback
|
|
3526
|
+
// setTimeout(() => {
|
|
3527
|
+
// this.wavPlayer.play();
|
|
3528
|
+
// this.vadPausedPlayer = false; // Reset flag
|
|
3529
|
+
// }, this.options.vadResumeDelay);
|
|
3523
3530
|
}
|
|
3524
3531
|
else {
|
|
3525
3532
|
console.log('onVADMisfire: VAD did not pause the player, no action taken to resume.');
|
|
3526
3533
|
}
|
|
3527
3534
|
},
|
|
3528
|
-
onSpeechEnd: () => {
|
|
3529
|
-
|
|
3530
|
-
|
|
3535
|
+
// onSpeechEnd: () => {
|
|
3536
|
+
// if (this.vadPausedPlayer) {
|
|
3537
|
+
// console.log('onSpeechEnd: VAD paused the player, resuming');
|
|
3538
|
+
// this.wavPlayer.play();
|
|
3539
|
+
// this.vadPausedPlayer = false; // Reset flag
|
|
3540
|
+
// } else {
|
|
3541
|
+
// console.log('onSpeechEnd: VAD did not pause the player, not resuming.');
|
|
3542
|
+
// }
|
|
3543
|
+
// },
|
|
3531
3544
|
})
|
|
3532
3545
|
.then((vad) => {
|
|
3533
3546
|
this.vad = vad;
|