mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-08 09:14:10 +00:00
fix(voice-call): clamp telephony tts timeout
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { MAX_TIMER_TIMEOUT_MS } from "openclaw/plugin-sdk/number-runtime";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import type { VoiceCallTtsConfig } from "./config.js";
|
||||
import type { CoreConfig } from "./core-bridge.js";
|
||||
@@ -179,6 +180,23 @@ describe("createTelephonyTtsProvider deepMerge hardening", () => {
|
||||
expect(provider.synthesisTimeoutMs).toBe(15000);
|
||||
});
|
||||
|
||||
it("clamps oversized configured timeoutMs", () => {
|
||||
const provider = createTelephonyTtsProvider({
|
||||
coreConfig: {
|
||||
messages: { tts: { provider: "openai", timeoutMs: Number.MAX_SAFE_INTEGER } },
|
||||
},
|
||||
runtime: {
|
||||
textToSpeechTelephony: async () => ({
|
||||
success: true,
|
||||
audioBuffer: Buffer.alloc(2),
|
||||
sampleRate: 8000,
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
expect(provider.synthesisTimeoutMs).toBe(MAX_TIMER_TIMEOUT_MS);
|
||||
});
|
||||
|
||||
it("keeps the telephony timeout default when timeoutMs is not configured", () => {
|
||||
const provider = createTelephonyTtsProvider({
|
||||
coreConfig: createCoreConfig(),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
||||
import {
|
||||
parseTtsDirectives,
|
||||
type SpeechModelOverridePolicy,
|
||||
@@ -60,8 +61,10 @@ export function createTelephonyTtsProvider(params: {
|
||||
);
|
||||
const providerConfigs = collectTelephonyProviderConfigs(ttsConfig);
|
||||
const activeProvider = normalizeProviderId(ttsConfig?.provider);
|
||||
const synthesisTimeoutMs =
|
||||
mergedConfig.messages?.tts?.timeoutMs ?? TELEPHONY_DEFAULT_TTS_TIMEOUT_MS;
|
||||
const synthesisTimeoutMs = resolveTimerTimeoutMs(
|
||||
mergedConfig.messages?.tts?.timeoutMs,
|
||||
TELEPHONY_DEFAULT_TTS_TIMEOUT_MS,
|
||||
);
|
||||
|
||||
return {
|
||||
synthesisTimeoutMs,
|
||||
|
||||
Reference in New Issue
Block a user