Are you trying to perform a live transcription on the audio stream? I'm not sure it handles that very well. I've had success with both the demo and my own code, which I haven't pushed to GitHub yet, but will soon.
But what I found worked was to collect chunks of data using the MediaRecorder:
stream = await navigator.mediaDevices.getUserMedia({
audio: true,
video: false,
});
const mimeType = "audio/webm";
let chunks = [];
recorder = new MediaRecorder(stream, { type: mimeType });
recorder.addEventListener("dataavailable", (event) => {
if (typeof event.data === "undefined") return;
if (event.data.size === 0) return;
chunks.push(event.data);
});
Then when the recording is complete, put the chunks into a Blob, get an array buffer from the Blob, and then decode the audio data from that array buffer with the Web Audio API, passing the result as the audio to the prompt API.
recorder.addEventListener("stop", async () => {
let recording = new Blob(chunks, {
type: mimeType,
});
const audioContext = new AudioContext();
const audioBuffer = await audioContext.decodeAudioData(
await recording.arrayBuffer()
);
const transcription = await transcriber.prompt([
{
role: "user",
content: [
{ type: "text", value: "Transcribe this short audio." },
{ type: "audio", value: audioBuffer },
],
},
]);
It looks like you're trying to do something similar using an AudioWorklet instead of MediaRecorder, but you are passing a blob to the prompt API and I think you will have to decode the audio data, as above, rather than just pass the blob. I'm guessing the prompt API is responding by describing JavaScript objects to you because it is just seeing an object it can't read, or even just [object Object], and it's doing what it can with it.
I would probably ensure you have the latest version of Canary, that might be causing the [noise] issues in the other demo. For reference I'm on 139.0.7218.0 (Official Build) canary (arm64) and it's working for me.