@absolutejs/voice 0.0.22-beta.590 → 0.0.22-beta.591
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.
- package/dist/index.js +7 -2
- package/dist/testing/index.js +7 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4574,16 +4574,19 @@ var createVoiceSession = (options) => {
|
|
|
4574
4574
|
const DRAIN_TAIL_BUFFER_MS = 300;
|
|
4575
4575
|
const DRAIN_QUIET_MS = 600;
|
|
4576
4576
|
const DRAIN_RENDER_START_MS = 4000;
|
|
4577
|
-
const
|
|
4577
|
+
const DRAIN_STREAMING_MAX_MS = 20000;
|
|
4578
|
+
const DRAIN_HARD_MAX_MS = 120000;
|
|
4578
4579
|
const drainAssistantSpeech = async (renderPendingSince) => {
|
|
4579
4580
|
const startedAt = Date.now();
|
|
4580
4581
|
const sleep3 = (delayMs) => new Promise((resolve) => {
|
|
4581
4582
|
setTimeout(resolve, delayMs);
|
|
4582
4583
|
});
|
|
4583
|
-
while (Date.now() - startedAt <
|
|
4584
|
+
while (Date.now() - startedAt < DRAIN_HARD_MAX_MS) {
|
|
4584
4585
|
const now = Date.now();
|
|
4585
4586
|
const renderStarted = lastAssistantAudioAt >= renderPendingSince || now - renderPendingSince >= DRAIN_RENDER_START_MS;
|
|
4586
4587
|
if (!renderStarted) {
|
|
4588
|
+
if (now - startedAt >= DRAIN_STREAMING_MAX_MS)
|
|
4589
|
+
return;
|
|
4587
4590
|
await sleep3(DRAIN_POLL_MS);
|
|
4588
4591
|
continue;
|
|
4589
4592
|
}
|
|
@@ -4591,6 +4594,8 @@ var createVoiceSession = (options) => {
|
|
|
4591
4594
|
const playbackDrained = assistantSpeechEndsAt + DRAIN_TAIL_BUFFER_MS <= now;
|
|
4592
4595
|
if (streamQuiet && playbackDrained)
|
|
4593
4596
|
return;
|
|
4597
|
+
if (!streamQuiet && now - startedAt >= DRAIN_STREAMING_MAX_MS)
|
|
4598
|
+
return;
|
|
4594
4599
|
await sleep3(DRAIN_POLL_MS);
|
|
4595
4600
|
}
|
|
4596
4601
|
};
|
package/dist/testing/index.js
CHANGED
|
@@ -6801,16 +6801,19 @@ var createVoiceSession = (options) => {
|
|
|
6801
6801
|
const DRAIN_TAIL_BUFFER_MS = 300;
|
|
6802
6802
|
const DRAIN_QUIET_MS = 600;
|
|
6803
6803
|
const DRAIN_RENDER_START_MS = 4000;
|
|
6804
|
-
const
|
|
6804
|
+
const DRAIN_STREAMING_MAX_MS = 20000;
|
|
6805
|
+
const DRAIN_HARD_MAX_MS = 120000;
|
|
6805
6806
|
const drainAssistantSpeech = async (renderPendingSince) => {
|
|
6806
6807
|
const startedAt = Date.now();
|
|
6807
6808
|
const sleep2 = (delayMs) => new Promise((resolve2) => {
|
|
6808
6809
|
setTimeout(resolve2, delayMs);
|
|
6809
6810
|
});
|
|
6810
|
-
while (Date.now() - startedAt <
|
|
6811
|
+
while (Date.now() - startedAt < DRAIN_HARD_MAX_MS) {
|
|
6811
6812
|
const now = Date.now();
|
|
6812
6813
|
const renderStarted = lastAssistantAudioAt >= renderPendingSince || now - renderPendingSince >= DRAIN_RENDER_START_MS;
|
|
6813
6814
|
if (!renderStarted) {
|
|
6815
|
+
if (now - startedAt >= DRAIN_STREAMING_MAX_MS)
|
|
6816
|
+
return;
|
|
6814
6817
|
await sleep2(DRAIN_POLL_MS);
|
|
6815
6818
|
continue;
|
|
6816
6819
|
}
|
|
@@ -6818,6 +6821,8 @@ var createVoiceSession = (options) => {
|
|
|
6818
6821
|
const playbackDrained = assistantSpeechEndsAt + DRAIN_TAIL_BUFFER_MS <= now;
|
|
6819
6822
|
if (streamQuiet && playbackDrained)
|
|
6820
6823
|
return;
|
|
6824
|
+
if (!streamQuiet && now - startedAt >= DRAIN_STREAMING_MAX_MS)
|
|
6825
|
+
return;
|
|
6821
6826
|
await sleep2(DRAIN_POLL_MS);
|
|
6822
6827
|
}
|
|
6823
6828
|
};
|