惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
Martin Fowler
Martin Fowler
博客园_首页
量子位
T
Tailwind CSS Blog
博客园 - Franky
G
Google Developers Blog
D
DataBreaches.Net
Vercel News
Vercel News
B
Blog
Recent Announcements
Recent Announcements
S
SegmentFault 最新的问题
M
MIT News - Artificial intelligence
爱范儿
爱范儿
博客园 - 【当耐特】
The Cloudflare Blog
H
Help Net Security
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
C
Check Point Blog
有赞技术团队
有赞技术团队
Microsoft Security Blog
Microsoft Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix: validate elevenlabs voice settings · openclaw/opencl...
steipete · 2026-05-29 · via Recent Commits to openclaw:main

@@ -78,6 +78,33 @@ function parseNumberValue(value: string): number | undefined {

78787979

export const isValidVoiceId = isValidElevenLabsVoiceId;

808081+

function normalizeVoiceSetting(value: unknown, min: number, max: number): number | undefined {

82+

const number = asFiniteNumber(value);

83+

return number !== undefined && number >= min && number <= max ? number : undefined;

84+

}

85+86+

function normalizeVoiceSettings(

87+

rawVoiceSettings: Record<string, unknown> | undefined,

88+

): Partial<ElevenLabsProviderConfig["voiceSettings"]> {

89+

return {

90+

...(normalizeVoiceSetting(rawVoiceSettings?.stability, 0, 1) == null

91+

? {}

92+

: { stability: normalizeVoiceSetting(rawVoiceSettings?.stability, 0, 1) }),

93+

...(normalizeVoiceSetting(rawVoiceSettings?.similarityBoost, 0, 1) == null

94+

? {}

95+

: { similarityBoost: normalizeVoiceSetting(rawVoiceSettings?.similarityBoost, 0, 1) }),

96+

...(normalizeVoiceSetting(rawVoiceSettings?.style, 0, 1) == null

97+

? {}

98+

: { style: normalizeVoiceSetting(rawVoiceSettings?.style, 0, 1) }),

99+

...(asBoolean(rawVoiceSettings?.useSpeakerBoost) == null

100+

? {}

101+

: { useSpeakerBoost: asBoolean(rawVoiceSettings?.useSpeakerBoost) }),

102+

...(normalizeVoiceSetting(rawVoiceSettings?.speed, 0.5, 2) == null

103+

? {}

104+

: { speed: normalizeVoiceSetting(rawVoiceSettings?.speed, 0.5, 2) }),

105+

};

106+

}

107+81108

function normalizeElevenLabsProviderConfig(

82109

rawConfig: Record<string, unknown>,

83110

): ElevenLabsProviderConfig {

@@ -100,16 +127,8 @@ function normalizeElevenLabsProviderConfig(

100127

| undefined,

101128

languageCode: trimToUndefined(raw?.languageCode),

102129

voiceSettings: {

103-

stability:

104-

asFiniteNumber(rawVoiceSettings?.stability) ?? DEFAULT_ELEVENLABS_VOICE_SETTINGS.stability,

105-

similarityBoost:

106-

asFiniteNumber(rawVoiceSettings?.similarityBoost) ??

107-

DEFAULT_ELEVENLABS_VOICE_SETTINGS.similarityBoost,

108-

style: asFiniteNumber(rawVoiceSettings?.style) ?? DEFAULT_ELEVENLABS_VOICE_SETTINGS.style,

109-

useSpeakerBoost:

110-

asBoolean(rawVoiceSettings?.useSpeakerBoost) ??

111-

DEFAULT_ELEVENLABS_VOICE_SETTINGS.useSpeakerBoost,

112-

speed: asFiniteNumber(rawVoiceSettings?.speed) ?? DEFAULT_ELEVENLABS_VOICE_SETTINGS.speed,

130+

...DEFAULT_ELEVENLABS_VOICE_SETTINGS,

131+

...normalizeVoiceSettings(rawVoiceSettings),

113132

},

114133

};

115134

}

@@ -128,13 +147,8 @@ function readElevenLabsProviderConfig(config: SpeechProviderConfig): ElevenLabsP

128147

defaults.applyTextNormalization,

129148

languageCode: trimToUndefined(config.languageCode) ?? defaults.languageCode,

130149

voiceSettings: {

131-

stability: asFiniteNumber(voiceSettings?.stability) ?? defaults.voiceSettings.stability,

132-

similarityBoost:

133-

asFiniteNumber(voiceSettings?.similarityBoost) ?? defaults.voiceSettings.similarityBoost,

134-

style: asFiniteNumber(voiceSettings?.style) ?? defaults.voiceSettings.style,

135-

useSpeakerBoost:

136-

asBoolean(voiceSettings?.useSpeakerBoost) ?? defaults.voiceSettings.useSpeakerBoost,

137-

speed: asFiniteNumber(voiceSettings?.speed) ?? defaults.voiceSettings.speed,

150+

...defaults.voiceSettings,

151+

...normalizeVoiceSettings(voiceSettings),

138152

},

139153

};

140154

}

@@ -159,21 +173,7 @@ function resolveVoiceSettingsOverride(

159173

const voiceSettings = asObject(overrides);

160174

return {

161175

...base,

162-

...(asFiniteNumber(voiceSettings?.stability) == null

163-

? {}

164-

: { stability: asFiniteNumber(voiceSettings?.stability) }),

165-

...(asFiniteNumber(voiceSettings?.similarityBoost) == null

166-

? {}

167-

: { similarityBoost: asFiniteNumber(voiceSettings?.similarityBoost) }),

168-

...(asFiniteNumber(voiceSettings?.style) == null

169-

? {}

170-

: { style: asFiniteNumber(voiceSettings?.style) }),

171-

...(asBoolean(voiceSettings?.useSpeakerBoost) == null

172-

? {}

173-

: { useSpeakerBoost: asBoolean(voiceSettings?.useSpeakerBoost) }),

174-

...(asFiniteNumber(voiceSettings?.speed) == null

175-

? {}

176-

: { speed: asFiniteNumber(voiceSettings?.speed) }),

176+

...normalizeVoiceSettings(voiceSettings),

177177

};

178178

}

179179

@@ -406,21 +406,7 @@ export function buildElevenLabsSpeechProvider(): SpeechProviderPlugin {

406406

}),

407407

voiceSettings: {

408408

...base.voiceSettings,

409-

...(asFiniteNumber(talkVoiceSettings?.stability) == null

410-

? {}

411-

: { stability: asFiniteNumber(talkVoiceSettings?.stability) }),

412-

...(asFiniteNumber(talkVoiceSettings?.similarityBoost) == null

413-

? {}

414-

: { similarityBoost: asFiniteNumber(talkVoiceSettings?.similarityBoost) }),

415-

...(asFiniteNumber(talkVoiceSettings?.style) == null

416-

? {}

417-

: { style: asFiniteNumber(talkVoiceSettings?.style) }),

418-

...(asBoolean(talkVoiceSettings?.useSpeakerBoost) == null

419-

? {}

420-

: { useSpeakerBoost: asBoolean(talkVoiceSettings?.useSpeakerBoost) }),

421-

...(asFiniteNumber(talkVoiceSettings?.speed) == null

422-

? {}

423-

: { speed: asFiniteNumber(talkVoiceSettings?.speed) }),

409+

...normalizeVoiceSettings(talkVoiceSettings),

424410

},

425411

};

426412

},

@@ -429,14 +415,18 @@ export function buildElevenLabsSpeechProvider(): SpeechProviderPlugin {

429415

const language = normalizeLowercaseStringOrEmpty(trimToUndefined(params.language));

430416

const latencyTier = asFiniteNumber(params.latencyTier);

431417

const voiceSettings = {

432-

...(asFiniteNumber(params.speed) == null ? {} : { speed: asFiniteNumber(params.speed) }),

433-

...(asFiniteNumber(params.stability) == null

418+

...(normalizeVoiceSetting(params.speed, 0.5, 2) == null

419+

? {}

420+

: { speed: normalizeVoiceSetting(params.speed, 0.5, 2) }),

421+

...(normalizeVoiceSetting(params.stability, 0, 1) == null

422+

? {}

423+

: { stability: normalizeVoiceSetting(params.stability, 0, 1) }),

424+

...(normalizeVoiceSetting(params.similarity, 0, 1) == null

434425

? {}

435-

: { stability: asFiniteNumber(params.stability) }),

436-

...(asFiniteNumber(params.similarity) == null

426+

: { similarityBoost: normalizeVoiceSetting(params.similarity, 0, 1) }),

427+

...(normalizeVoiceSetting(params.style, 0, 1) == null

437428

? {}

438-

: { similarityBoost: asFiniteNumber(params.similarity) }),

439-

...(asFiniteNumber(params.style) == null ? {} : { style: asFiniteNumber(params.style) }),

429+

: { style: normalizeVoiceSetting(params.style, 0, 1) }),

440430

...(asBoolean(params.speakerBoost) == null

441431

? {}

442432

: { useSpeakerBoost: asBoolean(params.speakerBoost) }),