

























@@ -16,6 +16,7 @@ const {
1616 transcribeAudioFileMock,
1717 textToSpeechStreamMock,
1818 textToSpeechMock,
19+ logVerboseMock,
1920} = vi.hoisted(() => {
2021type EventHandler = (...args: unknown[]) => unknown;
2122type MockConnection = {
@@ -111,6 +112,7 @@ const {
111112async (): Promise<unknown> => ({ success: false, error: "stream unavailable" }),
112113),
113114textToSpeechMock: vi.fn(async () => ({ success: true, audioPath: "/tmp/voice.mp3" })),
115+logVerboseMock: vi.fn(),
114116};
115117});
116118@@ -154,6 +156,16 @@ vi.mock("openclaw/plugin-sdk/agent-runtime", async () => {
154156};
155157});
156158159+vi.mock("openclaw/plugin-sdk/runtime-env", async () => {
160+const actual = await vi.importActual<typeof import("openclaw/plugin-sdk/runtime-env")>(
161+"openclaw/plugin-sdk/runtime-env",
162+);
163+return {
164+ ...actual,
165+logVerbose: logVerboseMock,
166+};
167+});
168+157169vi.mock("../runtime.js", () => ({
158170getDiscordRuntime: () => ({
159171mediaUnderstanding: {
@@ -218,6 +230,7 @@ describe("DiscordVoiceManager", () => {
218230textToSpeechStreamMock.mockResolvedValue({ success: false, error: "stream unavailable" });
219231textToSpeechMock.mockReset();
220232textToSpeechMock.mockResolvedValue({ success: true, audioPath: "/tmp/voice.mp3" });
233+logVerboseMock.mockClear();
221234createAudioResourceMock.mockClear();
222235});
223236@@ -760,6 +773,34 @@ describe("DiscordVoiceManager", () => {
760773);
761774});
762775776+it("logs a bounded inbound transcript preview for voice debugging", async () => {
777+transcribeAudioFileMock.mockResolvedValueOnce({
778+text: `hello from voice\n\n${"x".repeat(700)}`,
779+});
780+const client = createClient();
781+client.fetchMember.mockResolvedValue({
782+nickname: "Debug Speaker",
783+user: {
784+id: "u-debug",
785+username: "debug",
786+globalName: "Debug",
787+discriminator: "0001",
788+},
789+});
790+const manager = createManager({ groupPolicy: "open" }, client, {
791+commands: { useAccessGroups: false },
792+});
793+794+await processVoiceSegment(manager, "u-debug");
795+796+const transcriptLog = logVerboseMock.mock.calls
797+.map((call) => String(call[0]))
798+.find((message) => message.includes("transcript from Debug Speaker (u-debug)"));
799+expect(transcriptLog).toContain("hello from voice ");
800+expect(transcriptLog).not.toContain("\n");
801+expect(transcriptLog?.length).toBeLessThan(650);
802+});
803+763804it("plays streaming TTS audio before falling back to a synthesized file", async () => {
764805const release = vi.fn(async () => undefined);
765806textToSpeechStreamMock.mockResolvedValue({
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。