feat: Alexa TTS API サーバーを追加

- alexa-api/: Echo デバイスに TTS を送る Node.js API サーバー
  - server.js: alexa-remote2 を使わない直接 Alexa API 実装
    - GET /api/language で CSRF トークン取得
    - GET /api/bootstrap でカスタマー ID 取得
    - POST /api/behaviors/preview で TTS 実行
  - Dockerfile + docker-compose.yml: windmill_windmill-internal ネットワーク接続
  - auth4.js: Amazon Japan OpenID フローで Cookie 取得(WORKING)
- scripts/alexa_speak.ts: Windmill から alexa-api を呼び出すスクリプト

Windmill (u/admin/alexa_speak) → alexa_api:3500/speak → Echo デバイス の
パスで日本語 TTS が動作することを確認済み。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Akira
2026-03-02 16:34:22 +09:00
parent 593d13d8a1
commit 34107f98a2
13 changed files with 2083 additions and 0 deletions

30
scripts/alexa_speak.ts Normal file
View File

@@ -0,0 +1,30 @@
/**
* 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();
}