





















@@ -1,16 +1,28 @@
11import { statSync } from "node:fs";
2-import { EdgeTTS } from "node-edge-tts";
32import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
434+type EdgeTTSRuntimeConfig = {
5+voice?: string;
6+lang?: string;
7+outputFormat?: string;
8+saveSubtitles?: boolean;
9+proxy?: string;
10+rate?: string;
11+pitch?: string;
12+volume?: string;
13+timeout?: number;
14+};
15+516type EdgeTTSDeps = {
6-EdgeTTS: new (config: ConstructorParameters<typeof EdgeTTS>[0]) => {
17+EdgeTTS: new (config: EdgeTTSRuntimeConfig) => {
718ttsPromise: (text: string, outputPath: string) => Promise<unknown>;
819};
920};
102111-const defaultEdgeTTSDeps: EdgeTTSDeps = {
12- EdgeTTS,
13-};
22+async function loadDefaultEdgeTTSDeps(): Promise<EdgeTTSDeps> {
23+const { EdgeTTS } = await import("node-edge-tts");
24+return { EdgeTTS };
25+}
14261527export function inferEdgeExtension(outputFormat: string): string {
1628const normalized = normalizeLowercaseStringOrEmpty(outputFormat);
@@ -46,10 +58,11 @@ export async function edgeTTS(
4658};
4759timeoutMs: number;
4860},
49-deps: EdgeTTSDeps = defaultEdgeTTSDeps,
61+deps?: EdgeTTSDeps,
5062): Promise<void> {
5163const { text, outputPath, config, timeoutMs } = params;
52-const tts = new deps.EdgeTTS({
64+const resolvedDeps = deps ?? (await loadDefaultEdgeTTSDeps());
65+const tts = new resolvedDeps.EdgeTTS({
5366voice: config.voice,
5467lang: config.lang,
5568outputFormat: config.outputFormat,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。