





























@@ -3,10 +3,10 @@ import { tmpdir } from "node:os";
33import path from "node:path";
44import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
556-const runFfmpegMock = vi.hoisted(() => vi.fn());
6+const transcodeAudioBufferToOpusMock = vi.hoisted(() => vi.fn());
7788vi.mock("openclaw/plugin-sdk/media-runtime", () => ({
9-runFfmpeg: runFfmpegMock,
9+transcodeAudioBufferToOpus: transcodeAudioBufferToOpusMock,
1010}));
11111212import { buildMinimaxSpeechProvider } from "./speech-provider.js";
@@ -293,7 +293,7 @@ describe("buildMinimaxSpeechProvider", () => {
293293};
294294clearMinimaxAuthEnv();
295295vi.stubGlobal("fetch", vi.fn());
296-runFfmpegMock.mockReset();
296+transcodeAudioBufferToOpusMock.mockReset();
297297});
298298299299afterEach(async () => {
@@ -333,7 +333,7 @@ describe("buildMinimaxSpeechProvider", () => {
333333expect(body.model).toBe("speech-2.8-hd");
334334expect(body.text).toBe("Hello world");
335335expect(body.voice_setting.voice_id).toBe("English_expressive_narrator");
336-expect(runFfmpegMock).not.toHaveBeenCalled();
336+expect(transcodeAudioBufferToOpusMock).not.toHaveBeenCalled();
337337});
338338339339it("transcodes MiniMax MP3 to Opus for voice-note targets", async () => {
@@ -345,15 +345,7 @@ describe("buildMinimaxSpeechProvider", () => {
345345headers: { "Content-Type": "application/json" },
346346}),
347347);
348-runFfmpegMock.mockImplementationOnce(async (args: string[]) => {
349-const outputPath = args.at(-1);
350-if (typeof outputPath !== "string") {
351-throw new Error("missing ffmpeg output path");
352-}
353-await import("node:fs/promises").then((fs) =>
354-fs.writeFile(outputPath, Buffer.from("fake-opus-data")),
355-);
356-});
348+transcodeAudioBufferToOpusMock.mockResolvedValueOnce(Buffer.from("fake-opus-data"));
357349358350const result = await provider.synthesize({
359351text: "Hello world",
@@ -367,10 +359,12 @@ describe("buildMinimaxSpeechProvider", () => {
367359expect(result.fileExtension).toBe(".opus");
368360expect(result.voiceCompatible).toBe(true);
369361expect(result.audioBuffer.toString()).toBe("fake-opus-data");
370-expect(runFfmpegMock).toHaveBeenCalledWith(
371-expect.arrayContaining(["-c:a", "libopus", "-ar", "48000"]),
372-{ timeoutMs: 30000 },
373-);
362+expect(transcodeAudioBufferToOpusMock).toHaveBeenCalledWith({
363+audioBuffer: Buffer.from("fake-mp3-data"),
364+inputExtension: "mp3",
365+tempPrefix: "tts-minimax-",
366+timeoutMs: 30000,
367+});
374368});
375369376370it("applies overrides", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。