Files
windmill_workflow/scripts/alexa_speak.ts
2026-03-03 15:25:09 +09:00

21 lines
574 B
TypeScript

export async function main(
device: string,
text: string,
): Promise<{ ok: boolean; device: string; text: string }> {
const ALEXA_API_URL = "http://alexa_api:3500";
const res = await fetch(`${ALEXA_API_URL}/speak`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ device, text }), // ← SSMLなし、素のテキスト
});
if (!res.ok) {
const body = await res.json().catch(() => ({}));
throw new Error(`alexa-api error ${res.status}: ${JSON.stringify(body)}`);
}
return await res.json();
}