@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.
|
@@ -3481,6 +3481,7 @@ registerProcessor('audio_processor', AudioProcessor);
|
|
|
3481
3481
|
authorizeSessionEndpoint: options.authorizeSessionEndpoint,
|
|
3482
3482
|
metadata: options.metadata || {},
|
|
3483
3483
|
vadEnabled: options.vadEnabled || true,
|
|
3484
|
+
vadResumeDelay: options.vadResumeDelay || 500,
|
|
3484
3485
|
onConnect: options.onConnect || (() => { }),
|
|
3485
3486
|
onDisconnect: options.onDisconnect || (() => { }),
|
|
3486
3487
|
onError: options.onError || (() => { }),
|
|
@@ -3503,10 +3504,10 @@ registerProcessor('audio_processor', AudioProcessor);
|
|
|
3503
3504
|
model: 'v5',
|
|
3504
3505
|
// baseAssetPath: '/', // Use if bundling model locally
|
|
3505
3506
|
// onnxWASMBasePath: '/', // Use if bundling model locally
|
|
3506
|
-
positiveSpeechThreshold: 0.
|
|
3507
|
-
negativeSpeechThreshold: 0.
|
|
3508
|
-
redemptionFrames:
|
|
3509
|
-
minSpeechFrames:
|
|
3507
|
+
positiveSpeechThreshold: 0.3,
|
|
3508
|
+
negativeSpeechThreshold: 0.2,
|
|
3509
|
+
redemptionFrames: 25, // Number of frames of silence before onVADMisfire or onSpeechEnd is called. Effectively a delay before restarting.
|
|
3510
|
+
minSpeechFrames: 15,
|
|
3510
3511
|
preSpeechPadFrames: 0,
|
|
3511
3512
|
onSpeechStart: () => {
|
|
3512
3513
|
// Only pause agent audio if it's currently playing
|
|
@@ -3517,23 +3518,35 @@ registerProcessor('audio_processor', AudioProcessor);
|
|
|
3517
3518
|
}
|
|
3518
3519
|
else {
|
|
3519
3520
|
console.log('onSpeechStart: WavPlayer is not playing, VAD will not pause.');
|
|
3520
|
-
this.vadPausedPlayer = false;
|
|
3521
3521
|
}
|
|
3522
3522
|
},
|
|
3523
3523
|
onVADMisfire: () => {
|
|
3524
|
-
// 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
|
|
3524
|
+
// 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.
|
|
3525
3525
|
if (this.vadPausedPlayer) {
|
|
3526
|
-
console.log('
|
|
3526
|
+
console.log('onSpeechEnd: VAD paused the player, resuming');
|
|
3527
3527
|
this.wavPlayer.play();
|
|
3528
3528
|
this.vadPausedPlayer = false; // Reset flag
|
|
3529
|
+
// Option to extend delay in the case where the transcriber takes longer to detect a new turn
|
|
3530
|
+
// console.log('onVADMisfire: VAD paused the player, resuming in ' + this.options.vadResumeDelay + 'ms');
|
|
3531
|
+
// // Add configurable delay before resuming playback
|
|
3532
|
+
// setTimeout(() => {
|
|
3533
|
+
// this.wavPlayer.play();
|
|
3534
|
+
// this.vadPausedPlayer = false; // Reset flag
|
|
3535
|
+
// }, this.options.vadResumeDelay);
|
|
3529
3536
|
}
|
|
3530
3537
|
else {
|
|
3531
3538
|
console.log('onVADMisfire: VAD did not pause the player, no action taken to resume.');
|
|
3532
3539
|
}
|
|
3533
3540
|
},
|
|
3534
|
-
onSpeechEnd: () => {
|
|
3535
|
-
|
|
3536
|
-
|
|
3541
|
+
// onSpeechEnd: () => {
|
|
3542
|
+
// if (this.vadPausedPlayer) {
|
|
3543
|
+
// console.log('onSpeechEnd: VAD paused the player, resuming');
|
|
3544
|
+
// this.wavPlayer.play();
|
|
3545
|
+
// this.vadPausedPlayer = false; // Reset flag
|
|
3546
|
+
// } else {
|
|
3547
|
+
// console.log('onSpeechEnd: VAD did not pause the player, not resuming.');
|
|
3548
|
+
// }
|
|
3549
|
+
// },
|
|
3537
3550
|
})
|
|
3538
3551
|
.then((vad) => {
|
|
3539
3552
|
this.vad = vad;
|