OpenAI WebRTC Audio demo
OpenAI introduced a bunch of API options as we speak, together with a model new WebRTC API for organising a two-way audio dialog with their fashions.
They tweeted this opaque code instance:
async operate createRealtimeSession(inStream, outEl, token) {
const laptop = new RTCPeerConnection();
laptop.ontrack = e => outEl.srcObject = e.streams[0];
laptop.addTrack(inStream.getTracks()[0]);
const supply = await laptop.createOffer();
await laptop.setLocalDescription(supply);
const headers = { Authorization:Bearer ${token}, 'Content-Type': 'utility/sdp' };
const opts = { methodology: 'POST', physique: supply.sdp, headers };
const resp = await fetch('https://ift.tt/VSIbZMC', opts);
await laptop.setRemoteDescription({ kind: 'reply', sdp: await resp.textual content() });
return laptop;
}
So I pasted that into Claude and had it construct me this interactive demo for making an attempt out the brand new API.
My demo makes use of an OpenAI key immediately, however essentially the most fascinating side of the brand new WebRTC mechanism is its help for ephemeral tokens.
This solves a significant downside with their earlier realtime API: so as to connect with their endpoint you must present an API key, however that meant making that key seen to anybody who makes use of your utility. The solely safe solution to deal with this was to roll a full server-side proxy for his or her NetSocket API, simply so you may conceal your API key in your individual server. cloudflare/openai-workers-relay is an instance implementation of that sample.
Ephemeral tokens remedy that by letting you make a server-side name to request an ephemeral token which is able to solely enable a connection to be initiated to their WebRTC endpoint for the following 60 seconds. The consumer’s browser then begins the connection, which is able to final for as much as half-hour.
Tags: claude, audio, openai, ai, llms, ai-assisted-programming, instruments, generative-ai, api, safety, cloudflare
HI-FI News
through Simon Willison’s Weblog https://ift.tt/1Rg4HXT
December 18, 2024 at 12:50AM
-
Product on sale
Audiophile Vinyl Records Cleaning BundleOriginal price was: €69.90.€59.90Current price is: €59.90. incl. VAT -
Product on sale
Easy Start Vinyl Records Cleaning KitOriginal price was: €69.90.€59.90Current price is: €59.90. incl. VAT -
Vinyl Records Cleaner Easy Groove Concentrate€34.95 incl. VAT -
Easy Groove Super Set€199.00 incl. VAT -
Easy Groove Enzycaster – vinyl records prewash cleaner€34.95 incl. VAT -
Easy Groove Extreme MK. II- vinyl records prewash cleaner€45.00 incl. VAT -
Vinyl Records Cleaner – Easy Groove Virgin Concentrate€35.00 incl. VAT -
Easy Groove Spray&Wipe vinyl records cleaner€34.95 incl. VAT








