Skip to content

Commit f175d6b

Browse files
committed
Avoid implicit TTS clone defaults
1 parent 8940e2b commit f175d6b

3 files changed

Lines changed: 22 additions & 8 deletions

File tree

internal/openclaw/config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ func mergeTTS(cfg map[string]any, managed, next *ManagedState, result *SyncResul
124124
"apiKey": directToolAPIKey(result.APIKey),
125125
"baseUrl": result.ProxyAddr,
126126
"model": result.TTSModel.ID,
127-
"voice": "default",
128127
},
129128
},
130129
}

internal/openclaw/plugins/aima-local-tts/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ function resolveConfiguredTTSRoute(cfg) {
290290
model,
291291
baseUrl,
292292
apiKey: asString(provider.apiKey) || defaultLocalAPIKey,
293-
voice: asString(provider.voice) || "default",
294293
};
295294
}
296295

@@ -338,14 +337,19 @@ function buildTTSRequest(route, params, referenceAudioValue, referenceText) {
338337
if (!allowedResponseFormats.has(responseFormat)) {
339338
throw new Error(`unsupported response format: ${responseFormat}`);
340339
}
340+
const mode = asString(record.mode);
341+
const explicitVoice = readStringParam(record, ["voice"]);
342+
const wantsClone = mode === "voice_clone" || asOptionalBoolean(record.xVectorOnlyMode ?? record.x_vector_only_mode, false);
343+
if (wantsClone && !referenceAudioValue) {
344+
throw new Error("voice cloning requires referenceAudioPath");
345+
}
341346

342347
const payload = {
343348
model: route.model,
344349
text: readStringParam(record, ["text", "input"]),
345-
voice: readStringParam(record, ["voice"]) || route.voice || "default",
346350
response_format: responseFormat,
347-
use_default_reference: asOptionalBoolean(record.useDefaultReference ?? record.use_default_reference, true),
348351
};
352+
if (explicitVoice) payload.voice = explicitVoice;
349353

350354
for (const [source, target] of [
351355
["mode", "mode"],
@@ -439,10 +443,6 @@ export default function register(api) {
439443
type: "boolean",
440444
description: "Force x-vector-only voice cloning when true.",
441445
},
442-
useDefaultReference: {
443-
type: "boolean",
444-
description: "Allow the backend to use its configured default reference voice when no reference audio path is supplied.",
445-
},
446446
language: {
447447
type: "string",
448448
description: "Optional language hint for the backend.",

internal/openclaw/sync_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ func TestSyncWritesTTSProviderSchema(t *testing.T) {
265265
if got := openaiTTS["model"]; got != "qwen3-tts-0.6b" {
266266
t.Fatalf("messages.tts.providers.openai.model = %v, want qwen3-tts-0.6b", got)
267267
}
268+
if _, ok := openaiTTS["voice"]; ok {
269+
t.Fatalf("messages.tts.providers.openai.voice should not be written as an implicit default: %v", openaiTTS)
270+
}
268271
plugins := lookupMap(cfg, "plugins")
269272
if plugins == nil {
270273
t.Fatal("plugins missing after TTS sync")
@@ -1014,6 +1017,18 @@ func TestDeployPluginsWritesAIMAPlugins(t *testing.T) {
10141017
if !strings.Contains(string(ttsEntryData), `output path must stay within the OpenClaw workspace`) {
10151018
t.Fatal("expected TTS plugin to restrict output paths to the OpenClaw workspace")
10161019
}
1020+
if strings.Contains(string(ttsEntryData), `use_default_reference`) {
1021+
t.Fatal("TTS plugin must not ask backends to use a default reference voice")
1022+
}
1023+
if strings.Contains(string(ttsEntryData), `useDefaultReference`) {
1024+
t.Fatal("TTS plugin must not expose a default-reference control")
1025+
}
1026+
if strings.Contains(string(ttsEntryData), `route.voice ||`) {
1027+
t.Fatal("TTS plugin must not treat configured voice as an implicit request default")
1028+
}
1029+
if !strings.Contains(string(ttsEntryData), `voice cloning requires referenceAudioPath`) {
1030+
t.Fatal("expected TTS plugin to require explicit reference audio for voice cloning")
1031+
}
10171032

10181033
if _, err := os.Stat(filepath.Join(targetDir, "aima-local-image", "openclaw.plugin.json")); err != nil {
10191034
t.Fatalf("expected plugin manifest: %v", err)

0 commit comments

Comments
 (0)