Skip to content

Commit 62de17b

Browse files
authored
[Bug] Fix syntax error (#1515)
* Fix syntax error * Fix prompt format for audio transcription in session.promptStreaming
1 parent 517cf10 commit 62de17b

File tree

1 file changed

+8
-5
lines changed
  • functional-samples/ai.gemini-on-device-audio-scribe

1 file changed

+8
-5
lines changed

functional-samples/ai.gemini-on-device-audio-scribe/sidepanel.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ chrome.runtime.onMessage.addListener(async ({ data }) => {
2323
// Check if it's an audio file
2424
const audio = await fetch(data.objectUrl);
2525
content = await audio.blob();
26-
if (!content.type || !content.type.startsWidth('audio/')) {
26+
if (!content.type || !content.type.startsWith('audio/')) {
2727
return;
2828
}
2929
} catch (e) {
@@ -46,10 +46,13 @@ chrome.runtime.onMessage.addListener(async ({ data }) => {
4646
const session = await LanguageModel.create({
4747
expectedInputs: [{ type: 'audio' }]
4848
});
49-
const stream = session.promptStreaming([
50-
{ type: 'audio', content },
51-
'transcribe this audio'
52-
]);
49+
const stream = session.promptStreaming([{
50+
role: 'user',
51+
content: [
52+
{ type: 'text', value: 'transcribe this audio' },
53+
{ type: 'audio', value: content }
54+
]
55+
}]);
5356

5457
// Render streamed response
5558
let first = true;

0 commit comments

Comments
 (0)