Skip to content

Commit 6ed0c90

Browse files
authored
fix(multimodal): ensure audio samples is never smaller than 0 (#319)
1 parent e18d877 commit 6ed0c90

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

.changeset/gentle-jokes-refuse.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@livekit/agents": patch
3+
---
4+
5+
fix(multimodal): ensure audio samples is never smaller than 0

agents/src/multimodal/agent_playout.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,11 @@ export class PlayoutHandle extends EventEmitter {
5757
return Math.floor(this.totalPlayedTime * this.#sampleRate);
5858
}
5959

60-
return Math.floor(
61-
(this.pushedDuration - this.#audioSource.queuedDuration) * (this.#sampleRate / 1000),
60+
return Math.max(
61+
0,
62+
Math.floor(
63+
(this.pushedDuration - this.#audioSource.queuedDuration) * (this.#sampleRate / 1000),
64+
),
6265
);
6366
}
6467

0 commit comments

Comments
 (0)