Skip to content

Commit 823397a

Browse files
author
Guiners
committed
adding samples, test, lints
1 parent 141c244 commit 823397a

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ async function generateContent(
8080
}
8181

8282
const session = await ai.live.connect({
83-
model,
84-
config,
83+
model: modelId,
84+
config: config,
8585
callbacks: {
8686
onmessage: msg => responseQueue.push(msg),
8787
onerror: e => console.error('Error:', e.message),
@@ -98,11 +98,18 @@ async function generateContent(
9898
const audioChunks = await handleTurn(session);
9999

100100
session.close();
101-
return turns;
101+
102+
if (audioChunks.length > 0) {
103+
const audioBuffer = Buffer.concat(audioChunks);
104+
fs.writeFileSync('response.raw', audioBuffer);
105+
console.log('Received audio answer (saved to response.raw)');
106+
}
107+
108+
return audioChunks;
102109
}
103110
// Example output:
104111
//> Hello? Gemini, are you there?
105-
// Yes, I'm here. What would you like to talk about?
112+
// Received audio answer (saved to response.raw)
106113
// [END googlegenaisdk_live_audio_with_txt]
107114

108115
module.exports = {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const projectId = process.env.CAIP_PROJECT_ID;
2121
const sample = require('../live/live-audio-with-txt');
2222

2323
describe('live-audio-with-txt', () => {
24-
it('should generate text content from a text prompt and multiple images', async function () {
24+
it('should generate audio content from a text prompt', async function () {
2525
this.timeout(180000);
2626
const output = await sample.generateContent(projectId);
2727
console.log('Generated output:', output);

0 commit comments

Comments
 (0)