mirror of https://github.com/openclaw/openclaw.git
fix(tts): correct return mimeType and include ok in send details
This commit is contained in:
parent
60882db515
commit
229817fdc7
|
|
@ -39,10 +39,50 @@ describe("createTtsTool", () => {
|
|||
ok: true,
|
||||
deliveryMode: "return",
|
||||
audioPath: "/tmp/openclaw/tts-test/voice.mp3",
|
||||
mimeType: "audio/mpeg",
|
||||
sent: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("uses audio/ogg mimeType for voice-compatible return output", async () => {
|
||||
textToSpeechMock.mockResolvedValueOnce({
|
||||
success: true,
|
||||
audioPath: "/tmp/openclaw/tts-test/voice.opus",
|
||||
provider: "openai",
|
||||
voiceCompatible: true,
|
||||
});
|
||||
const tool = createTtsTool();
|
||||
|
||||
const result = await tool.execute("call-voice", {
|
||||
text: "hello",
|
||||
channel: "telegram",
|
||||
deliveryMode: "return",
|
||||
});
|
||||
|
||||
expect(result.details).toMatchObject({
|
||||
ok: true,
|
||||
deliveryMode: "return",
|
||||
mimeType: "audio/ogg",
|
||||
});
|
||||
});
|
||||
|
||||
it("includes ok=true in send mode success details", async () => {
|
||||
textToSpeechMock.mockResolvedValueOnce({
|
||||
success: true,
|
||||
audioPath: "/tmp/openclaw/tts-test/voice.mp3",
|
||||
provider: "openai",
|
||||
voiceCompatible: false,
|
||||
});
|
||||
const tool = createTtsTool();
|
||||
|
||||
const result = await tool.execute("call-send", {
|
||||
text: "hello",
|
||||
deliveryMode: "send",
|
||||
});
|
||||
|
||||
expect(result.details).toMatchObject({ ok: true, deliveryMode: "send" });
|
||||
});
|
||||
|
||||
it("returns validation error for invalid deliveryMode", async () => {
|
||||
const tool = createTtsTool();
|
||||
const result = await tool.execute("call-2", {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ export function createTtsTool(opts?: {
|
|||
ok: true,
|
||||
deliveryMode: "return",
|
||||
audioPath: result.audioPath,
|
||||
mimeType: "audio/mpeg",
|
||||
mimeType: result.voiceCompatible ? "audio/ogg" : "audio/mpeg",
|
||||
sent: false,
|
||||
provider: result.provider,
|
||||
},
|
||||
|
|
@ -87,7 +87,12 @@ export function createTtsTool(opts?: {
|
|||
lines.push(`MEDIA:${result.audioPath}`);
|
||||
return {
|
||||
content: [{ type: "text", text: lines.join("\n") }],
|
||||
details: { audioPath: result.audioPath, provider: result.provider, deliveryMode: "send" },
|
||||
details: {
|
||||
ok: true,
|
||||
audioPath: result.audioPath,
|
||||
provider: result.provider,
|
||||
deliveryMode: "send",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue