mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 21:10:43 +00:00
feat(plugin-sdk): share realtime transcription websocket sessions
This commit is contained in:
@@ -296,7 +296,7 @@ Current bundled provider examples:
|
||||
| `plugin-sdk/text-chunking` | Text chunking helpers | Outbound text chunking helper |
|
||||
| `plugin-sdk/speech` | Speech helpers | Speech provider types plus provider-facing directive, registry, and validation helpers |
|
||||
| `plugin-sdk/speech-core` | Shared speech core | Speech provider types, registry, directives, normalization |
|
||||
| `plugin-sdk/realtime-transcription` | Realtime transcription helpers | Provider types and registry helpers |
|
||||
| `plugin-sdk/realtime-transcription` | Realtime transcription helpers | Provider types, registry helpers, and shared WebSocket session helper |
|
||||
| `plugin-sdk/realtime-voice` | Realtime voice helpers | Provider types and registry helpers |
|
||||
| `plugin-sdk/image-generation-core` | Shared image-generation core | Image-generation types, failover, auth, and registry helpers |
|
||||
| `plugin-sdk/music-generation` | Music-generation helpers | Music-generation provider/request/result types |
|
||||
|
||||
@@ -258,7 +258,7 @@ explicitly promotes one as public.
|
||||
| `plugin-sdk/text-chunking` | Outbound text chunking helper |
|
||||
| `plugin-sdk/speech` | Speech provider types plus provider-facing directive, registry, and validation helpers |
|
||||
| `plugin-sdk/speech-core` | Shared speech provider types, registry, directive, and normalization helpers |
|
||||
| `plugin-sdk/realtime-transcription` | Realtime transcription provider types and registry helpers |
|
||||
| `plugin-sdk/realtime-transcription` | Realtime transcription provider types, registry helpers, and shared WebSocket session helper |
|
||||
| `plugin-sdk/realtime-voice` | Realtime voice provider types and registry helpers |
|
||||
| `plugin-sdk/image-generation` | Image generation provider types |
|
||||
| `plugin-sdk/image-generation-core` | Shared image-generation types, failover, auth, and registry helpers |
|
||||
|
||||
@@ -599,12 +599,34 @@ API key auth, and dynamic model resolution.
|
||||
id: "acme-ai",
|
||||
label: "Acme Realtime Transcription",
|
||||
isConfigured: () => true,
|
||||
createSession: (req) => ({
|
||||
connect: async () => {},
|
||||
sendAudio: () => {},
|
||||
close: () => {},
|
||||
isConnected: () => true,
|
||||
}),
|
||||
createSession: (req) => {
|
||||
const apiKey = String(req.providerConfig.apiKey ?? "");
|
||||
return createRealtimeTranscriptionWebSocketSession({
|
||||
providerId: "acme-ai",
|
||||
callbacks: req,
|
||||
url: "wss://api.example.com/v1/realtime-transcription",
|
||||
headers: { Authorization: `Bearer ${apiKey}` },
|
||||
onMessage: (event, transport) => {
|
||||
if (event.type === "session.created") {
|
||||
transport.sendJson({ type: "session.update" });
|
||||
transport.markReady();
|
||||
return;
|
||||
}
|
||||
if (event.type === "transcript.final") {
|
||||
req.onTranscript?.(event.text);
|
||||
}
|
||||
},
|
||||
sendAudio: (audio, transport) => {
|
||||
transport.sendJson({
|
||||
type: "audio.append",
|
||||
audio: audio.toString("base64"),
|
||||
});
|
||||
},
|
||||
onClose: (transport) => {
|
||||
transport.sendJson({ type: "audio.end" });
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
api.registerRealtimeVoiceProvider({
|
||||
|
||||
Reference in New Issue
Block a user