






















@@ -5,9 +5,10 @@ import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
55import type { RuntimeLogger } from "openclaw/plugin-sdk/plugin-runtime";
66import { resolveConfiguredCapabilityProvider } from "openclaw/plugin-sdk/provider-selection-runtime";
77import {
8+createRealtimeVoiceBridgeSession,
89getRealtimeVoiceProvider,
910listRealtimeVoiceProviders,
10-type RealtimeVoiceBridgeCallbacks,
11+type RealtimeVoiceBridgeSession,
1112type RealtimeVoiceProviderConfig,
1213type RealtimeVoiceProviderPlugin,
1314} from "openclaw/plugin-sdk/realtime-voice";
@@ -45,13 +46,6 @@ type ResolvedRealtimeProvider = {
4546providerConfig: RealtimeVoiceProviderConfig;
4647};
474848-type ActiveRealtimeBridge = {
49-acknowledgeMark(): unknown;
50-close(): unknown;
51-connect(): Promise<void> | void;
52-sendAudio(audio: Buffer): unknown;
53-};
54-5549function splitCommand(argv: string[]): { command: string; args: string[] } {
5650const [command, ...args] = argv;
5751if (!command) {
@@ -126,7 +120,7 @@ export async function startCommandRealtimeAudioBridge(params: {
126120stdio: ["ignore", "pipe", "pipe"],
127121});
128122let stopped = false;
129-let bridge: ActiveRealtimeBridge | null = null;
123+let bridge: RealtimeVoiceBridgeSession | null = null;
130124131125const stop = async () => {
132126if (stopped) {
@@ -174,15 +168,18 @@ export async function startCommandRealtimeAudioBridge(params: {
174168fullConfig: params.fullConfig,
175169providers: params.providers,
176170});
177-const callbacks: RealtimeVoiceBridgeCallbacks = {
178-onAudio: (muLaw) => {
179-if (!stopped) {
171+bridge = createRealtimeVoiceBridgeSession({
172+provider: resolved.provider,
173+providerConfig: resolved.providerConfig,
174+instructions: params.config.realtime.instructions,
175+audioSink: {
176+isOpen: () => !stopped,
177+sendAudio: (muLaw) => {
180178outputProcess.stdin?.write(muLaw);
181-}
182-},
183-onClearAudio: () => {},
184-onMark: () => {
185-bridge?.acknowledgeMark();
179+},
180+sendMark: () => {
181+bridge?.acknowledgeMark();
182+},
186183},
187184onTranscript: (role, text, isFinal) => {
188185if (isFinal) {
@@ -195,12 +192,6 @@ export async function startCommandRealtimeAudioBridge(params: {
195192void stop();
196193}
197194},
198-};
199-200-bridge = resolved.provider.createBridge({
201-providerConfig: resolved.providerConfig,
202-instructions: params.config.realtime.instructions,
203- ...callbacks,
204195});
205196206197inputProcess.stdout?.on("data", (chunk) => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。