Public
Edited
Dec 27
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
gain.gain.value = volume / 20.0;
}
Insert cell
audio_graph = {
messageProcessor.connect(gain);
gain.connect(audioContext.destination);

invalidation.then(() => {
gain.disconnect();
});
}
Insert cell
unprocessed = Generators.observe((notify) => {
const buffer = [];
notify(buffer);
client.on("conversation.updated", (event) => {
if (event?.delta?.audio) {
buffer.push(event.delta);
if (buffer.length <= 2) notify(buffer);
}
});
})
Insert cell
autoPlayAudio = {
({
prompt:
"can you play the audo in the incoming payload using web audio. Its packed in an 'Int16Array(51600) ' at incoming.at(-1).formatted.audio",
time: 1728369509847
});
while (unprocessed.length > 0) {
const audioData = unprocessed.shift()?.audio;
if (audioData instanceof Int16Array) {
const float32 = new Float32Array(audioData.length);
for (let i = 0; i < audioData.length; i++) {
float32[i] = audioData[i] / 32768;
}
messageProcessor.port.postMessage(float32);
}
}
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more