|
1 | 1 | import type { OpenClawConfig } from "../config/types.openclaw.js"; |
2 | 2 | import { normalizeOptionalLowercaseString } from "../shared/string-coerce.js"; |
| 3 | +import { resolveEffectiveTtsConfig } from "../tts/tts-config.js"; |
3 | 4 |
|
4 | 5 | const TTS_PROVIDER_CONFIG_RESERVED_KEYS = new Set([ |
5 | 6 | "auto", |
@@ -141,33 +142,43 @@ function addConfiguredTtsProviderIds(target: Set<string>, value: unknown): void |
141 | 142 |
|
142 | 143 | export function collectConfiguredSpeechProviderIds(config: OpenClawConfig): ReadonlySet<string> { |
143 | 144 | const configured = new Set<string>(); |
144 | | - addConfiguredTtsProviderIds(configured, config.messages?.tts); |
| 145 | + addConfiguredTtsProviderIds(configured, resolveEffectiveTtsConfig(config)); |
145 | 146 |
|
146 | 147 | const agents = config.agents; |
147 | 148 | if (isRecord(agents) && Array.isArray(agents.list)) { |
148 | 149 | for (const agent of agents.list) { |
149 | 150 | if (isRecord(agent)) { |
150 | | - addConfiguredTtsProviderIds(configured, agent.tts); |
| 151 | + if (typeof agent.id === "string") { |
| 152 | + addConfiguredTtsProviderIds( |
| 153 | + configured, |
| 154 | + resolveEffectiveTtsConfig(config, { agentId: agent.id }), |
| 155 | + ); |
| 156 | + } else { |
| 157 | + addConfiguredTtsProviderIds(configured, agent.tts); |
| 158 | + } |
151 | 159 | } |
152 | 160 | } |
153 | 161 | } |
154 | 162 |
|
155 | 163 | const channels = config.channels; |
156 | 164 | if (isRecord(channels)) { |
157 | | - for (const channelConfig of Object.values(channels)) { |
| 165 | + for (const [channelId, channelConfig] of Object.entries(channels)) { |
158 | 166 | if (!isRecord(channelConfig)) { |
159 | 167 | continue; |
160 | 168 | } |
161 | | - addConfiguredTtsProviderIds(configured, channelConfig.tts); |
| 169 | + addConfiguredTtsProviderIds(configured, resolveEffectiveTtsConfig(config, { channelId })); |
162 | 170 | if (isRecord(channelConfig.voice)) { |
163 | 171 | addConfiguredTtsProviderIds(configured, channelConfig.voice.tts); |
164 | 172 | } |
165 | 173 | if (isRecord(channelConfig.accounts)) { |
166 | | - for (const accountConfig of Object.values(channelConfig.accounts)) { |
| 174 | + for (const [accountId, accountConfig] of Object.entries(channelConfig.accounts)) { |
167 | 175 | if (!isRecord(accountConfig)) { |
168 | 176 | continue; |
169 | 177 | } |
170 | | - addConfiguredTtsProviderIds(configured, accountConfig.tts); |
| 178 | + addConfiguredTtsProviderIds( |
| 179 | + configured, |
| 180 | + resolveEffectiveTtsConfig(config, { channelId, accountId }), |
| 181 | + ); |
171 | 182 | if (isRecord(accountConfig.voice)) { |
172 | 183 | addConfiguredTtsProviderIds(configured, accountConfig.voice.tts); |
173 | 184 | } |
|
0 commit comments