























@@ -1,4 +1,4 @@
1-import { describe, expect, it } from "vitest";
1+import { describe, expect, it, vi } from "vitest";
22import { VERSION } from "../version.js";
33import {
44createRequestCaptureJsonFetch,
@@ -71,4 +71,21 @@ describe("transcribeOpenAiCompatibleAudio", () => {
7171expect(file).toBeInstanceOf(File);
7272expect((file as File).name).toBe("voice-note.m4a");
7373});
74+75+it("wraps malformed transcription JSON with a stable provider error", async () => {
76+const fetchFn = vi.fn<typeof fetch>().mockResolvedValueOnce(new Response("{ nope"));
77+78+await expect(
79+transcribeOpenAiCompatibleAudio({
80+buffer: Buffer.from("audio"),
81+fileName: "note.mp3",
82+apiKey: "test-key",
83+timeoutMs: 1000,
84+ fetchFn,
85+provider: "openai",
86+defaultBaseUrl: "https://api.openai.com/v1",
87+defaultModel: "gpt-4o-transcribe",
88+}),
89+).rejects.toThrow("Audio transcription failed: malformed JSON response");
90+});
7491});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。