/** * alexa_speak.ts * 指定した Echo デバイスにテキストを読み上げさせる Windmill スクリプト * * パラメータ: * device - デバイス名またはシリアル番号(例: "リビングエコー1", "プレハブ") * text - 読み上げるテキスト */ 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 }), }); if (!res.ok) { const body = await res.json().catch(() => ({})); throw new Error( `alexa-api error ${res.status}: ${JSON.stringify(body)}` ); } return await res.json(); }