Skip to content

Commit 374efb9

Browse files
author
Guiners
committed
adding samples, test, lints
1 parent 98d4ece commit 374efb9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

genai/live/live-conversation-audio-with-audio.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,17 @@ async function generateContent(
7373

7474
const responseQueue = [];
7575

76-
async function waitMessage() {
76+
async function waitMessage(timeoutMs = 60 * 1000) {
77+
const startTime = Date.now();
78+
7779
while (responseQueue.length === 0) {
80+
if (Date.now() - startTime > timeoutMs) {
81+
console.warn('No messages received within timeout. Exiting...');
82+
return null; // timeout occurred
83+
}
7884
await new Promise(resolve => setTimeout(resolve, 100));
7985
}
86+
8087
return responseQueue.shift();
8188
}
8289

0 commit comments

Comments
 (0)