OpenAI : GPT-Live 1
OpenAI full-duplex voice model for natural, expressive speech-to-speech conversations that listens while speaking and supports client delegation to your application.
Fournisseurs
Plusieurs fournisseurs peuvent héberger le même modèle. Choisissez-en un lorsque vous avez besoin d’un backend fixe, ou laissez le routage choisir parmi eux.
Langues prises en charge
Aucune liste de langues vérifiée pour ce modèle pour le moment.
Fonctionnalités
Full-duplex speech-to-speech over WebSocket, listening while it speaks.
speech_to_speech
Accepts text input and returns text output alongside audio.
text_input_output
The model manages when to listen and speak over a continuous audio stream, with interruption handling.
turn_taking
Streams timestamped transcripts of both input and output speech.
live_transcripts
Emits client delegation events for your application to handle and accepts application-provided results back into the conversation.
client_delegation
Code
Voix à voix en direct avec l’OpenAI SDK
Ouvre une session GPT-Live, diffuse question.pcm (PCM mono 16 bits à 24 kHz) en temps réel et enregistre la réponse parlée dans reply.pcm.
import { readFile, writeFile } from "node:fs/promises";
import { setTimeout as sleep } from "node:timers/promises";
import OpenAI from "openai";
import { LiveWS } from "openai/resources/live/ws";
const client = new OpenAI({
apiKey: process.env.ALLMODELS_API_KEY,
baseURL: "https://api.allmodels.io/oai"
});
const live = new LiveWS(client);
const reply = [];
let quiet;
live.on("session.output_audio.delta", ({ delta }) => reply.push(Buffer.from(delta, "base64")));
live.on("session.output_transcript.delta", () => {
// End the session two seconds after the reply's transcript goes quiet.
clearTimeout(quiet);
quiet = setTimeout(() => live.send({ type: "session.close" }), 2000);
});
live.on("session.closed", async () => {
await writeFile("reply.pcm", Buffer.concat(reply));
live.close();
});
live.on("error", console.error);
live.send({
type: "session.start",
session: {
model: "gpt-live-1",
audio: { format: { type: "audio/pcm", rate: 24000 }, output: { voice: "marin" } },
delegation: { type: "client" }
}
});
// Stream 100 ms frames in real time, then two seconds of silence.
const audio = Buffer.concat([await readFile("question.pcm"), Buffer.alloc(2 * 24000 * 2)]);
for (let offset = 0; offset < audio.length; offset += 4800) {
live.send({ type: "session.input_audio.append", audio: audio.subarray(offset, offset + 4800).toString("base64") });
await sleep(100);
}
