
























@@ -37,6 +37,7 @@ type OpenAITtsProviderConfig = {
3737speed?: number;
3838instructions?: string;
3939responseFormat?: OpenAiSpeechResponseFormat;
40+extraBody?: Record<string, unknown>;
4041};
41424243type OpenAITtsProviderOverrides = {
@@ -96,10 +97,19 @@ function responseFormatToFileExtension(
9697}
9798}
9899100+function readExtraBody(value: unknown): Record<string, unknown> | undefined {
101+const body = asObjectRecord(value);
102+if (!body || Object.keys(body).length === 0) {
103+return undefined;
104+}
105+return body;
106+}
107+99108function normalizeOpenAIProviderConfig(
100109rawConfig: Record<string, unknown>,
101110): OpenAITtsProviderConfig {
102111const raw = resolveOpenAIProviderConfigRecord(rawConfig);
112+const extraBody = readExtraBody(raw?.extraBody) ?? readExtraBody(raw?.extra_body);
103113return {
104114apiKey: normalizeResolvedSecretInputString({
105115value: raw?.apiKey,
@@ -115,6 +125,7 @@ function normalizeOpenAIProviderConfig(
115125speed: asFiniteNumber(raw?.speed),
116126instructions: trimToUndefined(raw?.instructions),
117127responseFormat: normalizeOpenAISpeechResponseFormat(raw?.responseFormat),
128+ extraBody,
118129};
119130}
120131@@ -129,6 +140,7 @@ function readOpenAIProviderConfig(config: SpeechProviderConfig): OpenAITtsProvid
129140instructions: trimToUndefined(config.instructions) ?? normalized.instructions,
130141responseFormat:
131142normalizeOpenAISpeechResponseFormat(config.responseFormat) ?? normalized.responseFormat,
143+extraBody: readExtraBody(config.extraBody) ?? readExtraBody(config.extra_body),
132144};
133145}
134146@@ -298,6 +310,7 @@ export function buildOpenAISpeechProvider(): SpeechProviderPlugin {
298310speed: overrides.speed ?? config.speed,
299311instructions: config.instructions,
300312 responseFormat,
313+extraBody: config.extraBody,
301314timeoutMs: req.timeoutMs,
302315});
303316return {
@@ -325,6 +338,7 @@ export function buildOpenAISpeechProvider(): SpeechProviderPlugin {
325338speed: overrides.speed ?? config.speed,
326339instructions: config.instructions,
327340responseFormat: outputFormat,
341+extraBody: config.extraBody,
328342timeoutMs: req.timeoutMs,
329343});
330344return { audioBuffer, outputFormat, sampleRate };
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。