From 3d64e6fd7cd2c6f8e4fdb795045ca306cf445af8 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 13 Jul 2026 21:04:52 +0100 Subject: [PATCH] refactor(microsoft): use node-edge-tts declarations --- extensions/microsoft/tts.ts | 27 +++++---------------------- src/types/node-edge-tts.d.ts | 30 ------------------------------ 2 files changed, 5 insertions(+), 52 deletions(-) delete mode 100644 src/types/node-edge-tts.d.ts diff --git a/extensions/microsoft/tts.ts b/extensions/microsoft/tts.ts index 53f42b48d6ad..37304ed0b018 100644 --- a/extensions/microsoft/tts.ts +++ b/extensions/microsoft/tts.ts @@ -5,29 +5,12 @@ import path from "node:path"; import { writeExternalFileWithinRoot } from "openclaw/plugin-sdk/security-runtime"; import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime"; -type EdgeTTSRuntimeConfig = { - voice?: string; - lang?: string; - outputFormat?: string; - saveSubtitles?: boolean; - proxy?: string; - rate?: string; - pitch?: string; - volume?: string; - timeout?: number; -}; - type EdgeTTSDeps = { - EdgeTTS: new (config: EdgeTTSRuntimeConfig) => { - ttsPromise: (text: string, outputPath: string) => Promise; - }; + EdgeTTS: new ( + ...args: ConstructorParameters + ) => Pick; }; -async function loadDefaultEdgeTTSDeps(): Promise { - const { EdgeTTS } = await import("node-edge-tts"); - return { EdgeTTS }; -} - function isMissingOutputFileError(error: unknown): boolean { return ( typeof error === "object" && @@ -89,8 +72,8 @@ export async function edgeTTS( throw new Error("Microsoft TTS text cannot be empty"); } - const resolvedDeps = deps ?? (await loadDefaultEdgeTTSDeps()); - const tts = new resolvedDeps.EdgeTTS({ + const EdgeTTSClass = deps?.EdgeTTS ?? (await import("node-edge-tts")).EdgeTTS; + const tts = new EdgeTTSClass({ voice: config.voice, lang: config.lang, outputFormat: config.outputFormat, diff --git a/src/types/node-edge-tts.d.ts b/src/types/node-edge-tts.d.ts deleted file mode 100644 index 9d69ccb1488a..000000000000 --- a/src/types/node-edge-tts.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** Minimal ambient types for node-edge-tts voice synthesis. */ -declare module "node-edge-tts" { - /** Options passed to the Edge TTS wrapper. */ - export type EdgeTTSOptions = { - voice?: string; - lang?: string; - outputFormat?: string; - saveSubtitles?: boolean; - proxy?: string; - rate?: string; - pitch?: string; - volume?: string; - timeout?: number; - }; - - /** Edge TTS class subset used by OpenClaw audio generation. */ - export class EdgeTTS { - constructor(options?: EdgeTTSOptions); - ttsPromise(text: string, outputPath: string): Promise; - } -} - -declare module "node-edge-tts/dist/drm.js" { - /** Chromium version constant required by the upstream token generator. */ - export const CHROMIUM_FULL_VERSION: string; - /** Trusted client token required by the upstream token generator. */ - export const TRUSTED_CLIENT_TOKEN: string; - /** Generate the DRM token needed by Edge TTS requests. */ - export function generateSecMsGecToken(): string; -}