Skip to content

Commit 8bde362

Browse files
author
Guiners
committed
adding samples, test, lints
1 parent 6e03ddb commit 8bde362

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ async function generateContent(
6262
const message = await waitMessage();
6363

6464
const sc = message.serverContent;
65-
if (sc.modelTurn.parts) {
65+
if (sc && sc.modelTurn && sc.modelTurn.parts) {
6666
for (const part of sc.modelTurn.parts) {
67-
if (part.inlineData.data) {
67+
if (part && part.inlineData && part.inlineData.data) {
6868
audioChunks.push(Buffer.from(part.inlineData.data));
6969
}
7070
}
7171
}
7272

73-
if (sc.turnComplete) {
73+
if (sc && sc.turnComplete) {
7474
done = true;
7575
}
7676
}

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,16 @@ async function generateContent(
5656
turns.push(message);
5757

5858
const sc = message.serverContent;
59-
if (sc.modelTurn) {
59+
if (sc && sc.modelTurn) {
6060
console.log('Model turn:', sc.modelTurn);
6161
}
62-
if (sc.inputTranscription) {
62+
if (sc && sc.inputTranscription) {
6363
console.log('Input transcript:', sc.inputTranscription.text);
6464
}
65-
if (sc.outputTranscription.text) {
65+
if (sc && sc.outputTranscription && sc.outputTranscription.text) {
6666
outputMessage.push(sc.outputTranscription.text);
6767
}
68-
69-
if (sc.turnComplete) {
68+
if (sc && sc.turnComplete) {
7069
done = true;
7170
}
7271
}

0 commit comments

Comments
 (0)