Skip to content

Commit 2f0b4d8

Browse files
authored
Refactor Speech handle and add ctx.waitForPlayout (#693)
1 parent 2ea1854 commit 2f0b4d8

File tree

6 files changed

+414
-118
lines changed

6 files changed

+414
-118
lines changed

.changeset/ten-teeth-stay.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+
refactor speech handle to allow waiting for playout in tool calls

agents/src/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,10 @@ export class Task<T> {
507507
get done(): boolean {
508508
return this.resultFuture.done;
509509
}
510+
511+
addDoneCallback(callback: () => void) {
512+
this.resultFuture.await.finally(callback);
513+
}
510514
}
511515

512516
export async function waitFor(tasks: Task<void>[]): Promise<void> {

0 commit comments

Comments
 (0)